socketIO-client icon indicating copy to clipboard operation
socketIO-client copied to clipboard

Index out of range error

Open Tadimsky opened this issue 7 years ago • 18 comments

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 avatar Mar 02 '17 16:03 Tadimsky

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

Tadimsky avatar Apr 11 '17 16:04 Tadimsky

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

robTheBuildr avatar Jan 19 '18 22:01 robTheBuildr

@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 :(

Tadimsky avatar Jan 20 '18 05:01 Tadimsky

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

l33klin avatar Jan 23 '18 06:01 l33klin

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

Tadimsky avatar Feb 09 '18 20:02 Tadimsky

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 avatar Feb 12 '18 12:02 Trickfilm400

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

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

Trickfilm400 avatar Feb 12 '18 12:02 Trickfilm400

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

Nixellion avatar Feb 25 '18 15:02 Nixellion

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

Roledenez avatar Mar 22 '18 13:03 Roledenez

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

Nixellion avatar Mar 31 '18 21:03 Nixellion

@Nixellion how did you fix it?

nicolamarinello avatar Apr 06 '18 16:04 nicolamarinello

@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

Nixellion avatar Apr 07 '18 00:04 Nixellion

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

Roledenez avatar Apr 11 '18 13:04 Roledenez

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

Nixellion avatar Apr 11 '18 13:04 Nixellion

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.

Jacobh2 avatar Sep 27 '18 13:09 Jacobh2

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

nicolamarinello avatar Sep 28 '18 19:09 nicolamarinello

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

jupe avatar Sep 28 '18 19:09 jupe

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.

zulufoxtrot avatar Nov 25 '18 17:11 zulufoxtrot