diff --git a/sleekxmpp/clientxmpp.py b/sleekxmpp/clientxmpp.py
index 7d000bf..9655eba 100644
--- a/sleekxmpp/clientxmpp.py
+++ b/sleekxmpp/clientxmpp.py
@@ -304,7 +304,7 @@ class ClientXMPP(BaseXMPP):
if sasl_mechs:
for sasl_mech in sasl_mechs:
self.features.append("sasl:%s" % sasl_mech.text)
- if 'sasl:PLAIN' in self.features:
+ if 'sasl:PLAIN' in self.features and self.boundjid.user:
if sys.version_info < (3, 0):
user = bytes(self.username)
password = bytes(self.password)
@@ -318,6 +318,8 @@ class ClientXMPP(BaseXMPP):
self.send("%s" % (
sasl_ns,
auth))
+ elif 'sasl:ANONYMOUS' in self.features and not self.boundjid.user:
+ self.send("")
else:
logging.error("No appropriate login method.")
self.disconnect()
diff --git a/sleekxmpp/xmlstream/jid.py b/sleekxmpp/xmlstream/jid.py
index 789410b..aa17c7b 100644
--- a/sleekxmpp/xmlstream/jid.py
+++ b/sleekxmpp/xmlstream/jid.py
@@ -94,6 +94,14 @@ class JID(object):
elif name in ('server', 'domain', 'host'):
self.domain = value
elif name in ('full', 'jid'):
+ if '@' not in value:
+ if '/' in value:
+ d, r = value.split('/', 1)
+ object.__setattr__(self, "_resource", r)
+ else:
+ d = value
+ object.__setattr__(self, "_domain", d)
+ else:
self.reset(value)
elif name == 'bare':
if '@' in value: