- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我快要为这个问题抓狂了。我正在使用我能想到的最简单的代码来测试 xmppy,但它一次又一次地失败。我过去使用过 sendxmpp,但我正在尝试将一些服务器端脚本迁移到使用 python,而不是通过管道输出到 sendxmpp。
无论如何:这是代码:
import xmpp
user = "actual.user@gmail.com"
password = "actualPassword"
server = 'talk.google.com'
jid = xmpp.JID(user)
connection = xmpp.Client(server)
connection.connect()
这是结果输出:
Invalid debugflag given: always
Invalid debugflag given: nodebuilder
DEBUG:
DEBUG: Debug created for /Users/ben/Desktop/PythonScripts/XMPP/xmpp/client.py
DEBUG: flags defined: always,nodebuilder
DEBUG: socket start Plugging <xmpp.transports.TCPsocket instance at 0x108daae60> into <xmpp.client.Client instance at 0x108daad88>
DEBUG: socket warn An error occurred while looking up _xmpp-client._tcp.talk.google.com
DEBUG: socket start Successfully connected to remote host ('talk.google.com', 5222)
DEBUG: dispatcher start Plugging <xmpp.dispatcher.Dispatcher instance at 0x108dbd050> into <xmpp.client.Client instance at 0x108daad88>
DEBUG: dispatcher info Registering namespace "unknown"
DEBUG: dispatcher info Registering protocol "unknown" as <class 'xmpp.protocol.Protocol'>(unknown)
DEBUG: dispatcher info Registering protocol "default" as <class 'xmpp.protocol.Protocol'>(unknown)
DEBUG: dispatcher info Registering namespace "http://etherx.jabber.org/streams"
DEBUG: dispatcher info Registering protocol "unknown" as <class 'xmpp.protocol.Protocol'>(http://etherx.jabber.org/streams)
DEBUG: dispatcher info Registering protocol "default" as <class 'xmpp.protocol.Protocol'>(http://etherx.jabber.org/streams)
DEBUG: dispatcher info Registering namespace "jabber:client"
DEBUG: dispatcher info Registering protocol "unknown" as <class 'xmpp.protocol.Protocol'>(jabber:client)
DEBUG: dispatcher info Registering protocol "default" as <class 'xmpp.protocol.Protocol'>(jabber:client)
DEBUG: dispatcher info Registering protocol "iq" as <class 'xmpp.protocol.Iq'>(jabber:client)
DEBUG: dispatcher info Registering protocol "presence" as <class 'xmpp.protocol.Presence'>(jabber:client)
DEBUG: dispatcher info Registering protocol "message" as <class 'xmpp.protocol.Message'>(jabber:client)
DEBUG: dispatcher info Registering handler <bound method Dispatcher.streamErrorHandler of <xmpp.dispatcher.Dispatcher instance at 0x108dbd050>> for "error" type-> ns->(http://etherx.jabber.org/streams)
DEBUG: dispatcher warn Registering protocol "error" as <class 'xmpp.protocol.Protocol'>(http://etherx.jabber.org/streams)
DEBUG: socket sent <?xml version='1.0'?>
<stream:stream xmlns="jabber:client" to="talk.google.com" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" >
DEBUG: socket got <stream:stream from="talk.google.com" id="B0E6462206621A27" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client">
<stream:features>
<starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls">
<required/>
</starttls>
<mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
<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-tls', u'urn:ietf:params:xml:ns:xmpp-sasl'] id->None
DEBUG: tls start Plugging <xmpp.transports.TLS instance at 0x108dbda28> into <xmpp.client.Client instance at 0x108daad88>
DEBUG: tls ok TLS supported by remote server. Requesting TLS start.
DEBUG: dispatcher info Registering handler <bound method TLS.StartTLSHandler of <xmpp.transports.TLS instance at 0x108dbda28>> for "proceed" type-> ns->(urn:ietf:params:xml:ns:xmpp-tls)
DEBUG: dispatcher warn Registering namespace "urn:ietf:params:xml:ns:xmpp-tls"
DEBUG: dispatcher info Registering protocol "unknown" as <class 'xmpp.protocol.Protocol'>(urn:ietf:params:xml:ns:xmpp-tls)
DEBUG: dispatcher info Registering protocol "default" as <class 'xmpp.protocol.Protocol'>(urn:ietf:params:xml:ns:xmpp-tls)
DEBUG: dispatcher warn Registering protocol "proceed" as <class 'xmpp.protocol.Protocol'>(urn:ietf:params:xml:ns:xmpp-tls)
DEBUG: dispatcher info Registering handler <bound method TLS.StartTLSHandler of <xmpp.transports.TLS instance at 0x108dbda28>> for "failure" type-> ns->(urn:ietf:params:xml:ns:xmpp-tls)
DEBUG: dispatcher warn Registering protocol "failure" as <class 'xmpp.protocol.Protocol'>(urn:ietf:params:xml:ns:xmpp-tls)
DEBUG: socket sent <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>
DEBUG: socket got <stream:error>
<host-unknown xmlns="urn:ietf:params:xml:ns:xmpp-streams"/>
<str:text xmlns:str="urn:ietf:params:xml:ns:xmpp-streams">Set the 'to' attribute of stream element to the domain part of the user's JID. Example: to='gmail.com'.</str:text>
</stream:error>
</stream:stream>
DEBUG: dispatcher ok Got http://etherx.jabber.org/streams/error stanza
DEBUG: dispatcher ok Dispatching error stanza with type-> props->[u'urn:ietf:params:xml:ns:xmpp-streams'] id->None
Traceback (most recent call last):
File "./sendXMPP.py", line 16, in <module>
print connection.connect()
File "/Users/ben/Desktop/PythonScripts/XMPP/xmpp/client.py", line 205, in connect
while not self.TLS.starttls and self.Process(1): pass
File "/Users/ben/Desktop/PythonScripts/XMPP/xmpp/dispatcher.py", line 303, in dispatch
handler['func'](session,stanza)
File "/Users/ben/Desktop/PythonScripts/XMPP/xmpp/dispatcher.py", line 215, in streamErrorHandler
raise exc((name,text))
xmpp.protocol.HostUnknown: (u'host-unknown', u"Set the 'to' attribute of stream element to the domain part of the user's JID. Example: to='gmail.com'.")
我到底做错了什么?
编辑:更新代码以显示更改。
新代码:
import xmpp
user = "actual.user@gmail.com"
password = "actualPassword"
server = 'talk.google.com'
jid = xmpp.JID(user)
connection = xmpp.Client(jid.getDomain())
connection.connect()
result = connection.auth(jid.getNode(), password,"TESTING")
新错误:
Invalid debugflag given: always
Invalid debugflag given: nodebuilder
DEBUG:
DEBUG: Debug created for /Users/ben/Desktop/PythonScripts/XMPP/xmpp/client.py
DEBUG: flags defined: always,nodebuilder
DEBUG: socket start Plugging <xmpp.transports.TCPsocket instance at 0x1033c0e60> into <xmpp.client.Client instance at 0x1033c0d88>
DEBUG: socket warn An error occurred while looking up _xmpp-client._tcp.gmail.com
DEBUG: socket error Failed to connect to remote host ('gmail.com', 5222): Operation timed out (60)
Traceback (most recent call last):
File "/Users/ben/Desktop/PythonScripts/XMPP/xmpp/transports.py", line 133, in connect
self._sock.connect((server[0], int(server[1])))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
error: [Errno 60] Operation timed out
DEBUG: socket stop Plugging <xmpp.transports.TCPsocket instance at 0x1033c0e60> out of <xmpp.client.Client instance at 0x1033c0d88>.
Traceback (most recent call last):
File "./sendXMPP.py", line 17, in <module>
result = connection.auth(jid.getNode(), password,"LFY-client")
File "/Users/ben/Desktop/PythonScripts/XMPP/xmpp/client.py", line 214, in auth
while not self.Dispatcher.Stream._document_attrs and self.Process(1): pass
AttributeError: Client instance has no attribute 'Dispatcher'
最佳答案
您不应该手动设置服务器 - xmpp.Client
将尝试自行解决:
import xmpp
jid = xmpp.JID("actual.user@gmail.com")
connection = xmpp.Client(jid.getDomain())
connection.connect()
应该可以正常工作。
关于python - xmpppy 连接到 gtalk 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12242349/
我正在使用 xmpppy。我创建了 50 多个 xmpp 连接线程。一段时间后我得到一个错误: File "transports.py", line 199, in pending_data retu
使用 XMPPPY 连接到 XMPP 服务器很简单。 from xmpp.client import Client as XMPPClient self.xmppClient = XMPPClient
如何使用此方法通过 xmpppy 发送数据:http://xmpp.org/extensions/xep-0047.html#send 我想我应该使用 IBB 类,但不知道该怎么做。 http://x
我正在尝试创建一个非常简单的脚本,它使用 python 的 xmpppy 通过 facebook 聊天发送消息。 import xmppFACEBOOK_ID = "username@chat.fac
我快要为这个问题抓狂了。我正在使用我能想到的最简单的代码来测试 xmppy,但它一次又一次地失败。我过去使用过 sendxmpp,但我正在尝试将一些服务器端脚本迁移到使用 python,而不是通过管道
我需要在连接到 gmail 时禁用 SSL 连接,我曾尝试过此代码: import xmpp username = 'username' passwd = 'password' to='friend@
我正在尝试使用 xmpppy 通过 Jabber(到 Google Talk)发送 XHTML(一个超链接),但找不到一个好的工作示例...我试过这个: http://intertwingly.net
我使用的代码: import xmppy jid = xmpp.JID('user@gmail.com') cl = xmpp.Client(jid.getDomain()) cl.connect(s
我在相关问题中找到了一个通过 xmpp(py) 发送消息的最小示例;见下文。但是当我执行脚本时,出现以下错误: client = xmpp.Client('gmail.com') Attribu
我正在尝试使用 xmpppy 访问我的 google talk 联系人的自定义状态消息。我做到了这一点: import xmpp import sys userID = 'myname@gmail
我是一名优秀的程序员,十分优秀!