【问题标题】:Python XMPP Error : Failed SASL authentification: <incorrect-encoding />Python XMPP 错误:SASL 身份验证失败:<incorrect-encoding />
【发布时间】:2017-01-09 15:53:45
【问题描述】:

我正在尝试让 TLS XMPP 客户端在 Ubuntu 14.04 上使用 python 2.7.6 工作。我启用了调试模式,整个连接看起来都很好,直到我收到错误消息error Failed SASL authentification: &lt;incorrect-encoding /&gt;。我已经通过桌面 Jabber 客户端验证了用户和密码帐户。这是我正在使用的代码。任何想法为什么这不起作用?:

#!/usr/bin/python

import xmpp

username= 'testxmpp'
passwd  = 'testtesttest'
to='jabber.somedomain.com'
msg='hello :)'



client = xmpp.Client('jabber.somedomain.com')
client.connect(server=('jabber.somedomain.com',5222))
client.auth(username, passwd, 'botty')
client.sendInitPresence()
message = xmpp.Message(to, msg)
message.setAttr('type', 'chat')
client.send(message)

这是程序调试输出的摘录:

DEBUG: socket       got   <failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
      <incorrect-encoding/>
      </failure>
    DEBUG: dispatcher   ok    Got urn:ietf:params:xml:ns:xmpp-sasl/failure stanza
    DEBUG: dispatcher   ok    Dispatching failure stanza with type-> props->[u'urn:ietf:params:xml:ns:xmpp-sasl'] id->None
    DEBUG: sasl         error Failed SASL authentification: <incorrect-encoding />
    DEBUG: sasl         stop  Plugging <xmpp.auth.SASL instance at 0x7f7c40711950> out of <xmpp.client.Client instance at 0x7f7c40784c68>.
    DEBUG: roster       start Plugging <xmpp.roster.Roster instance at 0x7f7c40711d40> into <xmpp.client.Client instance at 0x7f7c40784c68>
    DEBUG: dispatcher   info  Registering handler <bound method Roster.RosterIqHandler of <xmpp.roster.Roster instance at 0x7f7c40711d40>> for "iq" type->result ns->jabber:iq:roster(jabber:client)
    DEBUG: dispatcher   info  Registering handler <bound method Roster.RosterIqHandler of <xmpp.roster.Roster instance at 0x7f7c40711d40>> for "iq" type->set ns->jabber:iq:roster(jabber:client)
    DEBUG: dispatcher   info  Registering handler <bound method Roster.PresenceHandler of <xmpp.roster.Roster instance at 0x7f7c40711d40>> for "presence" type-> ns->(jabber:client)
    DEBUG: socket       sent  <iq type="get" id="22">
      <query xmlns="jabber:iq:roster" />

【问题讨论】:

    标签: python xmpp


    【解决方案1】:

    如果它对其他人有帮助,必须在 /usr/lib/python2.7/dist-packages/xmpp/auth.py 文件中进行编辑:

    ...
          elif "PLAIN" in mecs:
                sasl_data='%s\x00%s\x00%s'%(self.username+'@'+self._owner.Server,self.username,self.password)
                # ko - 2017-01-09 - fix for 'incorrect-encoding' error 
                # node=Node('auth',attrs={'xmlns':NS_SASL,'mechanism':'PLAIN'},payload=[base64.encodestring(sasl_data)])
                node=Node('auth',attrs={'xmlns':NS_SASL,'mechanism':'PLAIN'},payload=[base64.encodestring(sasl_data).replace('\r','').replace('\n','')]) 
            else:
    ...
    

    https://github.com/normanr/xmpppy/blob/master/xmpp/auth.py

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-31
      • 2017-05-09
      • 2016-08-20
      • 1970-01-01
      • 2013-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多