6

I'm getting the following error:

AttributeError: Client instance has no attribute 'Dispatcher'

while running the following code in 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)

Would be happy if someone knows how to fix it.

P.S. Full traceback of the error after the fix proposed by 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'

Before the fix:

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'
rok
  • 9,403
  • 17
  • 70
  • 126
  • Please include the *full* traceback for the error. – Martijn Pieters Aug 28 '13 at 10:09
  • @Martijn Pieters . I did. – rok Aug 28 '13 at 16:44
  • 1
    The AttributeError appears to be a problem that occurs *after* the connection failed due to a timeout. Are you behind a firewall at all? – Martijn Pieters Aug 28 '13 at 16:46
  • @Martijn Pieters. Sorry, it took me time to response. I've turned off the windows firewall and still get the same error. This computer is connected to domain network . Maybe, still there's a way to succeed to connect programmatically? Running wireshark during running the program, revealed that only 3 SYN messages sent to 173.194.70.125, exactly as when i connect with google talk, but then no responses are captured. – rok Sep 25 '13 at 12:22

2 Answers2

3

You need to specify a server you want to connect to.

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

After changing this I couldn't reproduce the AttributeError.

I would also advise you to use a correct JID to test your code. JID's are like E-Mails separated by an @, which is why in your sample code jid.getNode() returns nothing.

*Edit my Code example:

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()
N3RO
  • 46
  • 3
  • Thanks. I'm still getting the error, you can see the full traceback in my edited question. Sorry, I've fixed it in the question. Actually, I do have a real JID in my code. – rok Aug 28 '13 at 16:43
  • I added my working code into my answer. I hope that can help you. – N3RO Aug 28 '13 at 19:56
  • @ N3RO. Thanks, it worked at my home, but not at the computer connected to domain network. – rok Sep 25 '13 at 12:23
3

In your traceback it looks like you are trying to connect to talk.gmail.com which is a non existant domain, so the connection.connect statement will fail to open a connection.

Try to connect to talk.google.com which may be the right server's name.

Ander2
  • 5,569
  • 2
  • 23
  • 42