invisibleroads / socketIO-client

A socket.io client library for Python
http://pypi.python.org/pypi/socketIO-client
MIT License
447 stars 205 forks source link

Index out of range error #148

Open Tadimsky opened 7 years ago

Tadimsky commented 7 years ago

I'm using 0.7.2 and every so often I see the following error being logged:

Exception in thread Thread-4:
Traceback (most recent call last):
File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
    self.run()
File "/usr/lib/python3.4/threading.py", line 868, in run
    self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.4/dist-packages/socketIO_client/__init__.py", line 251, in wait
    self._process_packets()
File "/usr/local/lib/python3.4/dist-packages/socketIO_client/__init__.py", line 276, in _process_packets
    for engineIO_packet in self._transport.recv_packet():
File "/usr/local/lib/python3.4/dist-packages/socketIO_client/transports.py", line 158, in recv_packet
    packet_text)
File "/usr/local/lib/python3.4/dist-packages/socketIO_client/parsers.py", line 96, in parse_packet_text
    packet_type = int(get_character(packet_text, 0))
File "/usr/local/lib/python3.4/dist-packages/socketIO_client/symmetries.py", line 33, in get_character
    return chr(get_byte(x, index))
File "/usr/local/lib/python3.4/dist-packages/socketIO_client/symmetries.py", line 29, in get_byte
    return indexbytes(x, index)
IndexError: index out of range

It then is disconnected (but the events for disconnection never fire) and I then have to restart the service.

It looks kinda similar to #129 but not exactly the same.

Tadimsky commented 7 years ago

Any ideas here? Still seeing this issue intermittently...

Exception in thread Thread-4: Traceback (most recent call last): File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner self.run() File "/usr/lib/python3.4/threading.py", line 868, in run self._target(*self._args, **self._kwargs) File "/usr/local/lib/python3.4/dist-packages/socketIO_client/init.py", line 251, in wait self._process_packets() File "/usr/local/lib/python3.4/dist-packages/socketIO_client/init.py", line 276, in _process_packets for engineIO_packet in self._transport.recv_packet(): File "/usr/local/lib/python3.4/dist-packages/socketIO_client/transports.py", line 158, in recv_packet packet_text) File "/usr/local/lib/python3.4/dist-packages/socketIO_client/parsers.py", line 96, in parse_packet_text packet_type = int(get_character(packet_text, 0)) File "/usr/local/lib/python3.4/dist-packages/socketIO_client/symmetries.py", line 33, in get_character return chr(get_byte(x, index)) File "/usr/local/lib/python3.4/dist-packages/socketIO_client/symmetries.py", line 29, in get_byte return indexbytes(x, index) IndexError: index out of range

robTheBuildr commented 6 years ago

Hi Tadimsky, did you ever find a solution to this problem??

Tadimsky commented 6 years ago

@robertlevy11 no, unfortunately not. still have this issue... I'm using it to connect between a Raspberry Pi and a server for communication but the connection keeps going down :(

l33klin commented 6 years ago

Plus one, same error as your gays. Traceback (most recent call last): File "/Users/leek/Code/PycharmProjects/ExampleFunction/js.socketio_test.py", line 29, in <module> verify=False) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/socketIO_client/__init__.py", line 345, in __init__ resource, hurry_interval_in_seconds, **kw) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/socketIO_client/__init__.py", line 58, in __init__ self._transport File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/socketIO_client/__init__.py", line 66, in _transport self._engineIO_session = self._get_engineIO_session() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/socketIO_client/__init__.py", line 80, in _get_engineIO_session transport.recv_packet()) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/socketIO_client/transports.py", line 92, in recv_packet for engineIO_packet in decode_engineIO_content(response.content): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/socketIO_client/parsers.py", line 95, in decode_engineIO_content content, content_index) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/socketIO_client/parsers.py", line 202, in _read_packet_length while get_byte(content, content_index) not in [0, 1]: File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/socketIO_client/symmetries.py", line 36, in get_byte return six.indexbytes(x, index) IndexError: index out of range

Tadimsky commented 6 years ago

@l33klin @robertlevy11 do you guys know if there is some other library to use? Looks like this one is no longer active. :(

Trickfilm400 commented 6 years ago

I don't konw, i have the same error. I need a connection on the localhost from my server. On the Raspberry Pi it works without problems

Trickfilm400 commented 6 years ago

See here: Install the pip package: socketIO-client-nexus For me it worked!

https://github.com/nexus-devs/socketIO-client-2.0.3

Nixellion commented 6 years ago

+1, I have the same problem with this client. After a few hours this error shows up.

Roledenez commented 6 years ago

I am facing the same issue with Centos 6.9, ain't there a solution yet? this works fine with windows, only the error comes when testing with the centos

Nixellion commented 6 years ago

So far I solved it but setting restart time to like 60 minutes, seems to keep the client up 24\7 now

nicolamarinello commented 6 years ago

@Nixellion how did you fix it?

Nixellion commented 6 years ago

@nm3594 As I mention in my previous post, I set it to only listen for 1 hour, then reconnect.

while True:
    RESTART_DELAY = 60  # in minutes
    socketIO.wait(seconds=RESTART_DELAY * 60)  # conversion for minutes
Roledenez commented 6 years ago

@Nixellion the application I use must response less than 1 second. :(

Nixellion commented 6 years ago

@Roledenez Oh no, this code makes the client RESTART and RECONNECT each hour. It listens for an hour, responding instantly for any incoming message, then it restarts itself and listens for another hour. Or whatever time you set. It responds instantly.

Jacobh2 commented 6 years ago

I'm also having this issue:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "/socketlib.py", line 71, in _receive_events_thread
    self.socket_io.wait()
  File "/usr/local/lib/python3.7/site-packages/socketIO_client/__init__.py", line 251, in wait
    self._process_packets()
  File "/usr/local/lib/python3.7/site-packages/socketIO_client/__init__.py", line 276, in _process_packets
    for engineIO_packet in self._transport.recv_packet():
  File "/usr/local/lib/python3.7/site-packages/socketIO_client/transports.py", line 158, in recv_packet
    packet_text)
  File "/usr/local/lib/python3.7/site-packages/socketIO_client/parsers.py", line 96, in parse_packet_text
    packet_type = int(get_character(packet_text, 0))
  File "/usr/local/lib/python3.7/site-packages/socketIO_client/symmetries.py", line 33, in get_character
    return chr(get_byte(x, index))
  File "/usr/local/lib/python3.7/site-packages/socketIO_client/symmetries.py", line 29, in get_byte
    return indexbytes(x, index)
IndexError: index out of range

I managed to quickly reproduce it by spawning a lot (1000) threads, all connecting to the same server, and for each connection go into a loop and do emit.

nicolamarinello commented 6 years ago

At the end my problem was that I was using AWS. Now with the same library and the same code I don't have any problem using Google Cloud Compute Engine

jupe commented 6 years ago

@nicolamarinello what kind of problem you had with AWS? exactly same than in description? Did you use ALB/ELB? Have you seen any 502 rest failures? We have seen also problems with AWS with ALB but mostly with REST..

zulufoxtrot commented 5 years ago

I have the same problem with socketIO_client_nexus 0.7.6.

It can happen as early as 5 seconds after the connection is open.

The server is a nodeJS server using some implementation of socketIO 2. One thing I did change is putting the server behind a load balancer. I don't recall having this issue with a single instance of the server.