Getting index error #164

akhilpo opened this Issue May 6, 2012 · 9 comments

3 participants


When running as a client for facebook get, I am getting the following error occationally:

Error reading from XML stream.
no element found: line 1, column 108341
Traceback (most recent call last):
  File "<string>", line 82, in __next__
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python32\lib\site-packages\sleekxmpp\xmlstream\", line 1150, in _process
    if not self.__read_xml():
  File "C:\Python32\lib\site-packages\sleekxmpp\xmlstream\", line 1186, in __read_xml
    for event, xml in ET.iterparse(self.filesocket, (b'end', b'start')):
  File "<string>", line 96, in __next__
  File "<string>", line None
cElementTree.ParseError: no element found: line 1, column 108341

What's wrong here??

My code:

import sleekxmpp
import logging

def session_start(event):
    print('Session started')

def message(msg):
    if msg['type'] in ('chat','normal'):
        print("msg recieved")


jid = 'some'
password = 'somepassword'
addr = ('', 5222)
ipaddr = ('',5222)

chatbot = sleekxmpp.ClientXMPP(jid,password)
chatbot.add_event_handler("session_start", session_start)
chatbot.add_event_handler("message", message)

chatbot.auto_reconnect = True


It looks like you are using the 1.0 release, right?

That error means that the connection was cut. Looking at the Facebook XMPP group, it appears that Facebook is having issues with dropping clients today, which would be the cause of this issue.

If you use the develop branch, this error is handled properly (it is caught and handled in 1.0, it just also logs the exception trace).




I updated the package to the develop version and hit with another issue.

Traceback (most recent call last):
  File "D:\Work folder\Python\", line 32, in <module>
  File "C:\Python32\lib\site-packages\sleekxmpp\", line 154, in connect
  File "C:\Python32\lib\site-packages\sleekxmpp\xmlstream\", line 417, in connect
    func=self._connect, args=(reattempt,))
  File "C:\Python32\lib\site-packages\sleekxmpp\thirdparty\", line 69, in transition
    func=func, args=args, kwargs=kwargs)
  File "C:\Python32\lib\site-packages\sleekxmpp\thirdparty\", line 107, in transition_any
    return_val = func(*args,**kwargs) if func is not None else True
  File "C:\Python32\lib\site-packages\sleekxmpp\xmlstream\", line 454, in _connect
  File "C:\Python32\lib\site-packages\sleekxmpp\xmlstream\", line 947, in pick_dns_answer
    return next(self.dns_answers)
  File "C:\Python32\lib\site-packages\sleekxmpp\xmlstream\", line 96, in resolve
    ipv4 = socket.inet_pton(socket.AF_INET, host)
AttributeError: 'module' object has no attribute 'inet_pton'

Now it doesnt even connect.. :(


Reverted back to Master (v1.0) and it works fine. At least it connects and runs now.

Is that "socket..inet_pton()" supposed to be "socket.inet_aton()"?? :/
just a wild guess....


Ah, Windows. Looks like its socket module doesn't have inet_pton. One sec and I'll patch things to now use that method unless its available.


Ok, develop is updated to not use inet_pton unless its available. This may mean that specifying an IPv6 literal as the server name on a Windows machine may potentially behave oddly.

Is that "socket..inet_pton()" supposed to be "socket.inet_aton()"?? :/

socket.inet_aton only handles IPv4 literals. To handle IPv4 and IPv6 requires inet_pton.


Is there any better solution that handles both?
I will try the new one.

@bear bear added the Bug label Apr 12, 2015

@0xakhil I'm going to mark this as closed - the issue and version are old enough that if this is still happening it would be saner to have a new issue after seeing if it exists in the latest SleekXMPP

@bear bear closed this Apr 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment