I was trying to connect to facebook XMPP server using the sleekxmpp port that suports the SASL.

But was unable to connect...

 if not challenge['realm'] or not challenge['qop'] or not challenge['nonce']: KeyError: u'realm'

Looking at protocol http://xmpp.org/rfcs/rfc3920.html#sasl the function handler_sasl_digest_md5_auth was not handling 2 essential steps:

Step 7: "Server sends another [BASE64] encoded challenge to client:"

Step 8: "Client responds to the challenge:"


    self.sendPriorityRaw("""<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>%s</response>""" % base64.encodestring(response)[:-1])
    self.digest_auth_started = True
   logging.warn("handler_sasl_digest_md5_auth called while digest_auth_started is True (has already begun)")
   self.sendPriorityRaw("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl' />")