Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Getting index error #164

Closed
akhilpo opened this Issue · 9 comments

3 participants

@akhilpo

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\xmlstream.py", line 1150, in _process
    if not self.__read_xml():
  File "C:\Python32\lib\site-packages\sleekxmpp\xmlstream\xmlstream.py", 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):
    chatbot.send_presence()
    print('Session started')
    chatbot.get_roster()

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

        msg.reply("Thanks").send()

jid = 'some id@chat.facebook.com'
password = 'somepassword'
addr = ('chat.facebook.com', 5222)
ipaddr = ('209.85.175.125',5222)

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

chatbot.auto_reconnect = True

chatbot.connect(addr)
chatbot.process(block=True)
@legastero
Collaborator

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).

@akhilpo

thanks..

@akhilpo

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

Traceback (most recent call last):
  File "D:\Work folder\Python\sleekxmppyproj32.py", line 32, in <module>
    chatbot.connect(addr)
  File "C:\Python32\lib\site-packages\sleekxmpp\clientxmpp.py", line 154, in connect
    reattempt=reattempt)
  File "C:\Python32\lib\site-packages\sleekxmpp\xmlstream\xmlstream.py", line 417, in connect
    func=self._connect, args=(reattempt,))
  File "C:\Python32\lib\site-packages\sleekxmpp\thirdparty\statemachine.py", line 69, in transition
    func=func, args=args, kwargs=kwargs)
  File "C:\Python32\lib\site-packages\sleekxmpp\thirdparty\statemachine.py", 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\xmlstream.py", line 454, in _connect
    self.address[1])
  File "C:\Python32\lib\site-packages\sleekxmpp\xmlstream\xmlstream.py", line 947, in pick_dns_answer
    return next(self.dns_answers)
  File "C:\Python32\lib\site-packages\sleekxmpp\xmlstream\resolver.py", 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.. :(

@akhilpo

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....

@legastero
Collaborator

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.

@legastero
Collaborator

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.

@legastero
Collaborator
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.

@akhilpo

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

@bear bear added the Bug label
@bear
Collaborator

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.