IBB Example Scripts Not Working With OpenFire #204

zeroSteiner opened this Issue Oct 31, 2012 · 6 comments


None yet

2 participants

zeroSteiner commented Oct 31, 2012 edited

I'm using openfire and I've been trying to get a simple file transfer working using IBB. One of the exceptions I've been getting is:
ERROR : 'utf8' codec can't decode byte 0xab in position 1: invalid start byte
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/sleekxmpp-1.1.10-py2.7.egg/sleekxmpp/xmlstream/xmlstream.py", line 1644, in _event_runner
File "/usr/lib/python2.7/site-packages/sleekxmpp-1.1.10-py2.7.egg/sleekxmpp/xmlstream/handler/callback.py", line 76, in run
File "/usr/lib/python2.7/site-packages/sleekxmpp-1.1.10-py2.7.egg/sleekxmpp/plugins/xep_0047/ibb.py", line 146, in _handle_data
File "/usr/lib/python2.7/site-packages/sleekxmpp-1.1.10-py2.7.egg/sleekxmpp/plugins/xep_0047/stream.py", line 83, in _recv_data
data = iq['ibb_data']['data']
File "/usr/lib/python2.7/site-packages/sleekxmpp-1.1.10-py2.7.egg/sleekxmpp/xmlstream/stanzabase.py", line 687, in getitem
return getattr(self, get_method)(**kwargs)
File "/usr/lib/python2.7/site-packages/sleekxmpp-1.1.10-py2.7.egg/sleekxmpp/plugins/xep_0047/stanza.py", line 53, in get_data
return from_b64(b64_data)
File "/usr/lib/python2.7/site-packages/sleekxmpp-1.1.10-py2.7.egg/sleekxmpp/plugins/xep_0047/stanza.py", line 18, in from_b64
return bytes(base64.b64decode(bytes(data))).decode('utf-8')
File "/usr/lib64/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xab in position 1: invalid start byte

Furthermore, when I use PDB to set a break point on XEP_0047._handle_data it never gets trigged. When I leave the default window and block size my sender just hangs in IBBytestream.send where it calls self.send_window.acquire(). When trying to look into this I also noticed that the sender's _recv_ack method was never called which I think is because the receiver never responds to the data that is being sent. My ultimate goal is to accept the stream and read all the data with a call to IBBytestream.read()

I'm using Python 2.7.3


What kind of file are you transferring?


It's a BZ2-compressed tarball, so it's full of non-printable characters.


Ok, that should be fixed now in master and develop. If not, let me know.



The UnicodeDecodeError seems to be fixed but my code still blocks when I call read() on the IBBStream.

-> data = stream.read()
(Pdb) s
-> def read(self, block=True, timeout=None, **kwargs):
(Pdb) n
-> if not self.stream_started.is_set() or
-> self.stream_in_closed.is_set():
-> if timeout is not None:
-> try:
-> return self.recv_queue.get(block, timeout)

And then it just hangs forever.
I think I'm still having trouble because I don't think XEP_0047._handle_data is ever executed to add the data to the queue.

Thanks for the help.


Ah, are you including threaded=True in your ibb_stream_start handler?


I think I'm getting closer. I specified threaded=True like you suggested. I'm able to read data now but it seems that my receiver is missing the last chunk of data. For example my sender is transmitting 23234 bytes of data in a single call to stream.sendall and the stream was created with a block size of 8192 for the sake of testing. My receiver only gets 16384 bytes. And when I set the block size to 4096 it reads 20480 bytes. If on my sender I append add stream.send("") then my receiver gets all of the data.

My receiver is retrieving the data in a loop to the read call with a timeout of 10 seconds and breaking when the data that's returned is None. I've also tried to do this with the ibb_stream_data event so I wasn't dealing with a read loop and the result was the same, the last even is never sent.

@horazont horazont added a commit to horazont/SleekXMPP that referenced this issue Dec 3, 2012
@legastero @horazont legastero + horazont Turns out not all data is UTF-8, so don't try to decode it.
Fixes issue #204
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment