我使用的代码:
import xmppy
jid = xmpp.JID('user@gmail.com')
cl = xmpp.Client(jid.getDomain())
cl.connect(server=('talk.google.com',5222))
cl.auth('user@gmail.com', 'password','something')
它似乎一直工作到连接,我得到'tls'作为连接的回报。在那之后,cl.auth
失败了。我尝试使用带有和不带有 @gmail.com 的用户名。我尝试过使用不同的用户,所以我的密码没有错。我尝试使用 5223 而不是 5222,在这种情况下,我会得到 'ssl' 作为回报。
这是我得到的调试输出:
DEBUG: socket got <stream:stream from="gmail.com" id="960A4092BC8F9722" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client">
<stream:features>
<mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
<mechanism>PLAIN</mechanism>
<mechanism>X-GOOGLE-TOKEN</mechanism>
<mechanism>X-OAUTH2</mechanism>
</mechanisms>
</stream:features>
DEBUG: dispatcher warn Unknown stanza: features
DEBUG: dispatcher ok Dispatching unknown stanza with type-> props->[u'urn:ietf:params:xml:ns:xmpp-sasl'] id->None
DEBUG: sasl start Plugging <xmpp.auth.SASL instance at 0x2f22998> into <xmpp.client.Client instance at 0x2f19bd8>
DEBUG: dispatcher info Registering handler <bound method SASL.SASLHandler of <xmpp.auth.SASL instance at 0x2f22998>> for "challenge" type-> ns->(urn:ietf:params:xml:ns:xmpp-sasl)
DEBUG: dispatcher warn Registering namespace "urn:ietf:params:xml:ns:xmpp-sasl"
DEBUG: dispatcher info Registering protocol "unknown" as <class 'xmpp.protocol.Protocol'>(urn:ietf:params:xml:ns:xmpp-sasl)
DEBUG: dispatcher info Registering protocol "default" as <class 'xmpp.protocol.Protocol'>(urn:ietf:params:xml:ns:xmpp-sasl)
DEBUG: dispatcher warn Registering protocol "challenge" as <class 'xmpp.protocol.Protocol'>(urn:ietf:params:xml:ns:xmpp-sasl)
DEBUG: dispatcher info Registering handler <bound method SASL.SASLHandler of <xmpp.auth.SASL instance at 0x2f22998>> for "failure" type-> ns->(urn:ietf:params:xml:ns:xmpp-sasl)
DEBUG: dispatcher warn Registering protocol "failure" as <class 'xmpp.protocol.Protocol'>(urn:ietf:params:xml:ns:xmpp-sasl)
DEBUG: dispatcher info Registering handler <bound method SASL.SASLHandler of <xmpp.auth.SASL instance at 0x2f22998>> for "success" type-> ns->(urn:ietf:params:xml:ns:xmpp-sasl)
DEBUG: dispatcher warn Registering protocol "success" as <class 'xmpp.protocol.Protocol'>(urn:ietf:params:xml:ns:xmpp-sasl)
DEBUG: socket sent <auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">Y3MxMGIwNTlAZ21haWwuY29tQGdtYWlsLmNvbQBjczEwYjA1OUBnbWFpbC5jb20AcHZ6bXZoN3FjYzE=</auth>
DEBUG: socket error Socket error while receiving data
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/xmpppy-0.5.0rc1-py2.7.egg/xmpp/transports.py", line 153, in receive
try: received = self._recv(BUFLEN)
SSLError: [Errno 8] _ssl.c:1359: EOF occurred in violation of protocol
DEBUG: client stop Disconnect detected
DEBUG: socket error Socket operation failed
DEBUG: sasl stop Plugging <xmpp.auth.SASL instance at 0x2f22998> out of <xmpp.client.Client instance at 0x2f19bd8>.