`TypeError: can only concatenate str (not "bytes") to str` when connecting with ejabberd server
mnswdhw opened this issue · 6 comments
import socket
from socketfunc import *
from xmpp import *
from lxml.etree import ElementTree, Element, SubElement
import lxml.etree as etree
import pubsubclient
from io import StringIO
import string
from random import Random
user="joker@localhost"
password="joker"
server="localhost"
jid = JID(user)
connection = Client(server)
connection.connect()
result = connection.auth(jid.getNode(),password)
connection.sendInitPresence()
I have a user joker registered on ejabberd server with the same username and password and i am trying to connect and open a session with the ejabberd server but running the above code leads to the below issue
Traceback (most recent call last):
File "test.py", line 79, in <module>
result = connection.auth(jid.getNode(),password)
File "/home/manas/anaconda3/lib/python3.7/site-packages/xmpp/client.py", line 228, in auth
while self.SASL.startsasl=='in-process' and self.Process(1): pass
File "/home/manas/anaconda3/lib/python3.7/site-packages/xmpp/dispatcher.py", line 127, in Process
raise _pendingException[0](_pendingException[1]).with_traceback(_pendingException[2])
File "/home/manas/anaconda3/lib/python3.7/site-packages/xmpp/dispatcher.py", line 305, in dispatch
handler['func'](session,stanza)
File "/home/manas/anaconda3/lib/python3.7/site-packages/xmpp/auth.py", line 181, in SASLHandler
self.DEBUG('Got challenge:'+data,'ok')
TypeError: can only concatenate str (not "bytes") to str
However i am able to connect to prosody xmpp server using the same above code but ofcourse different user credentials.
Please look into this issue
Thanks
I have the same problem! Do you have any clue how to solve this?
Are you using python2.7? This looks a bit like using python3 on python2.x code.
@gdt Double checked. My code from example https://pastebin.com/wijSmn1z. Output from "python3.8 test.py" -> https://pastebin.com/hx8ZsCmz.
And it didn't get the msg. (
Hi there,
thanks for writing in. Can you give the patch from #45 a try?
python3 -m venv .venv
source .venv/bin/activate
pip install git+https://github.com/xmpppy/xmpppy.git@amo/fix-python3
wget https://pastebin.com/raw/wijSmn1z -O test.py
python test.py
With kind regards,
Andreas.
P.S.: This module is primarily maintained for Python 2, while we slightly improved compatibility with Python 3. In any case, I want to also recommend https://github.com/poezio/slixmpp by @poezio and contributors.
Thanks, the problem with error is gone! But I still can't connect and send msg. Maybe this time I am doing something wrong.) (log after executing https://pastebin.com/hGVeEe1v). Thanks for the advice about slixmpp. I will test it and will update the issue if the problem was on my side)