我的代码是:
import xmpp
jabberid = "admin@mydomain.com"
password = "password"
receiver = "admin@mydomain.com"
message = "hello world"
jid = xmpp.protocol.JID(jabberid)
connection = xmpp.Client(server=jid.getDomain())
connection.connect()
connection.auth(user=jid.getNode(), password=password,resource=jid.getResource())
我收到此错误:
File "/home/eduardo/.local/share/virtualenvs/xmpp-sv-KIKvfzDF/lib/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/home/eduardo/.local/share/virtualenvs/xmpp-sv-KIKvfzDF/lib/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/eduardo/Desktop/adiconf/xmpp-sv/api/main/user/routes.py", line 33, in add
connection.auth(user=str(jid.getNode()), password=str(password), resource=str(jid.getResource()))
File "/home/eduardo/.local/share/virtualenvs/xmpp-sv-KIKvfzDF/lib/python3.6/site-packages/xmpp/client.py", line 228, in auth
while self.SASL.startsasl=='in-process' and self.Process(1): pass
File "/home/eduardo/.local/share/virtualenvs/xmpp-sv-KIKvfzDF/lib/python3.6/site-packages/xmpp/dispatcher.py", line 126, in Process
raise _pendingException[0](_pendingException[1]).with_traceback(_pendingException[2])
File "/home/eduardo/.local/share/virtualenvs/xmpp-sv-KIKvfzDF/lib/python3.6/site-packages/xmpp/dispatcher.py", line 304, in dispatch
handler['func'](session,stanza)
File "/home/eduardo/.local/share/virtualenvs/xmpp-sv-KIKvfzDF/lib/python3.6/site-packages/xmpp/auth.py", line 179, in SASLHandler
self.DEBUG('Got challenge:'+data,'ok')
TypeError: must be str, not bytes
我正在使用 xmpppy 模块,但我不知道为什么?因为我传递给 connection.auth 的参数都是字符串