2013-08-23 2 views
5
나는 다음과 같은 오류를 받고 있어요

:파이썬 XMPP 간단한 클라이언트 오류

AttributeError: Client instance has no attribute 'Dispatcher' 

파이썬 2.7에서 다음 코드를 실행하는 동안 누군가가 그것을 해결하는 방법을 알고 있다면

import xmpp 

user= '[email protected]' 
password="pass" 

jid = xmpp.JID(user) 
connection = xmpp.Client(jid.getDomain()) 
connection.connect() 
connection.auth(jid.getNode(),password) 

행복 할 것이다.

P. 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' 

:

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' 
+0

오류에 대해 * 전체 * 추적을 포함하십시오. –

+0

@Martijn Pieters. 나는 그랬다. – user1264304

+1

AttributeError는 시간 초과로 인해 연결이 실패한 * 후에 발생하는 문제인 것으로 보입니다. 방화벽 뒤에있어? –

답변

3

당신은 연결할 서버를 지정해야합니다.

connection.connect(server=('serveradress.com', portnumber)) 

변경 후 AttributeError를 재현 할 수 없습니다.

올바른 JID를 사용하여 코드를 테스트하는 것이 좋습니다. JID는 @로 구분 된 전자 메일과 비슷하므로 샘플 코드에서 jid.getNode()는 아무 것도 반환하지 않습니다. 가 아닌 존재하지 않는 도메인입니다 talk.gmail.com 연결을 시도하는, 그래서 connection.connect 문이 연결을 여는 데 실패처럼 보이는 당신의 추적에서

import xmpp 

user = '[email protected]' 
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() 
+0

. 아직 오류가 발생했습니다. 편집 한 질문에서 전체 추적을 볼 수 있습니다. 죄송합니다. 질문에 수정했습니다. 사실, 제 코드에는 진짜 JID가 있습니다. – user1264304

+0

제 대답에 제 작업 코드를 추가했습니다. 나는 당신을 도울 수 있기를 바랍니다. – N3RO

+0

@ N3RO 고마워, 그것은 내 집에서 일했지만 도메인 네트워크에 연결된 컴퓨터에서는 작동하지 않습니다. – user1264304

3

:

* 내 코드 예제를 편집합니다.

올바른 서버 이름 일 수있는 talk.google.com에 연결을 시도하십시오.

관련 문제