Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/351.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python xmpp简单客户端错误_Python_Xmpp_Xmpppy - Fatal编程技术网

python xmpp简单客户端错误

python xmpp简单客户端错误,python,xmpp,xmpppy,Python,Xmpp,Xmpppy,我得到以下错误: AttributeError: Client instance has no attribute 'Dispatcher' 在python 2.7中运行以下代码时: import xmpp user= 'uname@gmail.com' password="pass" jid = xmpp.JID(user) connection = xmpp.Client(jid.getDomain()) connection.connect() connection.auth

我得到以下错误:

AttributeError: Client instance has no attribute 'Dispatcher'
在python 2.7中运行以下代码时:

import xmpp 

user= 'uname@gmail.com'
password="pass"

jid = xmpp.JID(user) 
connection = xmpp.Client(jid.getDomain()) 
connection.connect() 
connection.auth(jid.getNode(),password)
如果有人知道如何修理它,我会很高兴的

注:N3RO提出修复后,对错误的完整回溯:

C:\Users\krasnovi\Desktop\temp\xmpp tests>python xmpp.client.py
Invalid debugflag given: always
Invalid debugflag given: nodebuilder
DEBUG:
DEBUG: Debug created for build\bdist.win-amd64\egg\xmpp\client.py
DEBUG:  flags defined: always,nodebuilder
DEBUG: socket       start Plugging <xmpp.transports.TCPsocket instance at 0x0000
0000027C1708> into <xmpp.client.Client instance at 0x00000000027C1588>
DEBUG: socket       warn  An error occurred while looking up _xmpp-client._tcp.t
alk.gmail.com
DEBUG: socket       error Failed to connect to remote host ('talk.gmail.com', 52
23): getaddrinfo failed (11004)
Traceback (most recent call last):
  File "build\bdist.win-amd64\egg\xmpp\transports.py", line 133, in connect
    self._sock.connect((server[0], int(server[1])))
  File "C:\Python27\lib\socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
gaierror: [Errno 11004] getaddrinfo failed
DEBUG: socket       stop  Plugging <xmpp.transports.TCPsocket instance at 0x0000
0000027C1708> out of <xmpp.client.Client instance at 0x00000000027C1588>.
Traceback (most recent call last):
  File "xmpp.client.py", line 11, in <module>
    connection.auth(jid.getNode(),password)
  File "build\bdist.win-amd64\egg\xmpp\client.py", line 214, in auth
AttributeError: Client instance has no attribute 'Dispatcher'
C:\Users\krasnovi\Desktop\temp\xmpp tests>python xmpp.client.py
给定的调试标志无效:始终
给定的调试标志无效:nodebuilder
调试:
调试:为build\bdist.win-amd64\egg\xmpp\client.py创建调试
调试:定义的标志:始终,nodebuilder
调试:套接字开始插入
调试:套接字警告查找_xmpp-client时出错。_tcp.t
alk.gmail.com
调试:套接字错误无法连接到远程主机('talk.gmail.com',52
23):getaddrinfo失败(11004)
回溯(最近一次呼叫最后一次):
文件“build\bdist.win-amd64\egg\xmpp\transports.py”,第133行,在connect中
self._sock.connect((服务器[0],int(服务器[1]))
文件“C:\Python27\lib\socket.py”,第224行,meth格式
返回getattr(self.\u sock,name)(*args)
gaierror:[Errno 11004]getaddrinfo失败
调试:套接字停止从中插入。
回溯(最近一次呼叫最后一次):
文件“xmpp.client.py”,第11行,在
connection.auth(jid.getNode(),密码)
文件“build\bdist.win-amd64\egg\xmpp\client.py”,第214行,在auth中
AttributeError:客户端实例没有属性“Dispatcher”
在修复之前:

Invalid debugflag given: always
Invalid debugflag given: nodebuilder
DEBUG:
DEBUG: Debug created for build\bdist.win-amd64\egg\xmpp\client.py
DEBUG:  flags defined: always,nodebuilder
DEBUG: socket       start Plugging <xmpp.transports.TCPsocket instance at 0x0000
0000027ED708> into <xmpp.client.Client instance at 0x00000000027ED588>
DEBUG: socket       error Failed to connect to remote host ('xmpp.l.google.com.'
, 5222): A connection attempt failed because the connected party did not properl
y respond after a period of time, or established connection failed because conne
cted host has failed to respond (10060)
Traceback (most recent call last):
  File "build\bdist.win-amd64\egg\xmpp\transports.py", line 133, in connect
    self._sock.connect((server[0], int(server[1])))
  File "C:\Python27\lib\socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
error: [Errno 10060] A connection attempt failed because the connected party did
 not properly respond after a period of time, or established connection failed b
ecause connected host has failed to respond
DEBUG: socket       stop  Plugging <xmpp.transports.TCPsocket instance at 0x0000
0000027ED708> out of <xmpp.client.Client instance at 0x00000000027ED588>.
Traceback (most recent call last):
  File "xmpp.client.py", line 11, in <module>
    connection.auth(jid.getNode(),password)
  File "build\bdist.win-amd64\egg\xmpp\client.py", line 214, in auth
AttributeError: Client instance has no attribute 'Dispatcher'
给定的调试标志无效:始终
给定的调试标志无效:nodebuilder
调试:
调试:为build\bdist.win-amd64\egg\xmpp\client.py创建调试
调试:定义的标志:始终,nodebuilder
调试:套接字开始插入
调试:套接字错误无法连接到远程主机('xmpp.l.google.com'
,5222):连接尝试失败,因为连接方未正确连接
y在一段时间后响应,或由于连接失败而建立连接
CTE主机未能响应(10060)
回溯(最近一次呼叫最后一次):
文件“build\bdist.win-amd64\egg\xmpp\transports.py”,第133行,在connect中
self._sock.connect((服务器[0],int(服务器[1]))
文件“C:\Python27\lib\socket.py”,第224行,meth格式
返回getattr(self.\u sock,name)(*args)
错误:[Errno 10060]连接尝试失败,因为连接方失败了
一段时间后未正确响应,或建立的连接失败b
e因为连接的主机无法响应
调试:套接字停止从中插入。
回溯(最近一次呼叫最后一次):
文件“xmpp.client.py”,第11行,在
connection.auth(jid.getNode(),密码)
文件“build\bdist.win-amd64\egg\xmpp\client.py”,第214行,在auth中
AttributeError:客户端实例没有属性“Dispatcher”

您需要指定要连接到的服务器

connection.connect(server=('serveradress.com', portnumber))
更改此项后,我无法复制AttributeError

我还建议您使用正确的JID来测试代码。 JID类似于用@分隔的电子邮件,这就是为什么在示例代码中JID.getNode()不返回任何内容

*编辑我的代码示例:

import xmpp

user = 'username@gmail.com'
password = 'password'

jid = xmpp.JID(user)

connection = xmpp.Client(jid.getDomain())
connection.connect(server=('talk.google.com', 5223))
connection.auth(jid.getNode(), password)
connection.sendInitPresence()

在您的回溯中,您似乎正在尝试连接到
talk.gmail.com
,这是一个不存在的域,因此
connection.connect
语句将无法打开连接


请尝试连接到
talk.google.com
,这可能是正确的服务器名称。

请包含错误的完整回溯。@Martijn Pieters。是的。AttributeError似乎是连接因超时而失败后出现的问题。“你在防火墙后面吗?”马蒂恩·皮特斯。对不起,我花了很长时间才回复。我已经关闭了windows防火墙,但仍然收到相同的错误。此计算机已连接到域网络。也许,仍然有一种方法可以成功地通过编程进行连接?在运行程序的过程中运行wireshark,发现只有3条SYN消息发送到173.194.70.125,与我连接google talk时完全一样,但没有捕获任何响应。谢谢。我仍然得到错误,你可以在我编辑的问题中看到完整的回溯。对不起,我已经把问题解决了。事实上,我的代码中有一个真正的JID。我在我的答案中添加了我的工作代码。我希望这能帮助你。@N3RO。谢谢,它在我家工作,但在连接到域网络的计算机上不起作用。