简体   繁体   中英

XMPP connecting to server (Python)

I am currently following a tutorial/getting started on creating a Google Talk Bot

I have made the EchoBot but it fails at runtime with the following error:

File "echobot.py", line 59, in <module>
if xmpp.connect(('talk.google.com'), '5222'):
File "C:\Python31\Lib\sleekxmpp\clientxmpp.py", line 143, in connect
reattempt=reattempt)
File "C:\Python31\Lib\sleekxmpp\xmlstream\xmlstream.py", line 372, in connect
self.address = (host, int(port))
ValueError: invalid literal for int() with base 10: 'a'

I have tried Python 3,3 , 3,2 and 3,1 interpreter with the same result.

I can not get these lines from the tutorial to compile with either of the compilers:

if sys.version_info < (3, 0):
reload(sys)
sys.setdefaultencoding('utf8')

The code from within the Bot where it fails is as follows:

if xmpp.connect(('talk.google.com'), '5222'):
    xmpp.process(block=True)
else:
    print('Fekk ikkje kopla til')

Thanks for any tips/help!

You have written something wrong:

xmpp.connect(('talk.google.com', '5222'))
                               |
                             there you missed a comma

and the second thing could be to put the port to the second place.

xmpp.connect(('talk.google.com', 5222), '5222')

I do not know of the second argument but

Internet Adresses are almost always tuples of (HOST, PORT)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM