简体   繁体   中英

Connecting to Jabber Server Via Proxy in Python (XMPPY)

Trying to connect to jabber with proxy:

 > JCON = xmpp.Client(server=SERVER, port=PORT, debug=[])
 > con=JCON.connect(server=(CONNECT_SERVER, PORT), proxy=(127.0.0.1, 80), secure=0,use_srv=True)

Without proxy it connects fine. Is the proxy syntax right? Referring to 'Client.py' in XMPPY ( https://github.com/normanr/xmpppy/blob/master/xmpp/client.py ) might help to understand the syntax.

Hoping for a response soon!

From the code you linked:

'proxy' argument is a dictionary with mandatory keys 'host' and 'port' (proxy address)

You need to change it into a dictionary, like this.

   con=JCON.connect(server=(CONNECT_SERVER, PORT), proxy={'host':'127.0.0.1', 'port':'80'}, secure=0,use_srv=True)

If you need authentication, you add 'user':'me','password':'secret' to the dictionary, like this

   con=JCON.connect(server=(CONNECT_SERVER, PORT), proxy={'host':'127.0.0.1', 'port':'80','user':'me','password':'secret'}, secure=0,use_srv=True)

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