2013-08-23 21 views
5
aşağıdaki hatayı alıyorum

:piton xmpp basit istemci hatası

AttributeError: Client instance has no attribute 'Dispatcher' 

piton 2.7 aşağıdaki kodu çalıştırırken: Birisi bunu düzeltmek için nasıl biliyorsa

import xmpp 

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

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

mutlu olurdu.

P.S. N3RO önerdiği düzeltme sonrasında hata Tam geri izleme: Önce düzeltme

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

Lütfen hata için * tam * traceback'i ekleyin. –

+0

@Martijn Pieters. Yaptım. – user1264304

+1

AttributeError, bir zaman aşımı nedeniyle bağlantı başarısız olduğunda * oluşan bir sorun gibi görünüyor. Güvenlik duvarının arkasında mısınız? –

cevap

3

Sen bağlanmak istediğiniz bir sunucuyu belirtmek gerekir.

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

bu değiştirdikten sonra ben AttributeError yeniden.

Ayrıca, kodunuzu sınamak için doğru JID kullanmanız önerilir. JID'ler, bir @ ile ayrılmış E-postaları gibidir, bu nedenle örnek kodunuzda jid.getNode() hiçbir şey döndürmez. Eğer bir sigara var domain olup talk.gmail.com bağlanmaya çalışıyorsunuz, bu yüzden connection.connect ifadesi bir bağlantı açmak için başarısız olur gibi görünüyor senin traceback olarak

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

Teşekkürler. Hala hatayı alıyorum, düzenlediğim soruda tam izini görebilirsiniz. Üzgünüm, soruyu çözdüm. Aslında, kodumda gerçek bir JID var. – user1264304

+0

Çalışma kodumu yanıtıma ekledim. Umarım bu size yardımcı olabilir. – N3RO

+0

@ N3RO. Teşekkürler, evimde çalıştı, ancak etki alanı ağına bağlı bilgisayar başında değil. – user1264304

3

:

* benim Kod örneği düzenleyin.

Doğru sunucunun adı olan talk.google.com'a bağlanmayı deneyin.