bombsimon / hltv-python

📺 HLTV live score implementation with Socket.IO
MIT License
15 stars 3 forks source link

JSONDecodeError related to Invalid Namespace #9

Open samayala22 opened 2 years ago

samayala22 commented 2 years ago

Hey, having a hard time understanding a way to fix this "Invalid Namespace" response parsing issue.

The extra debug info was obtained using sio = socketio.AsyncClient(logger=True, engineio_logger=True) in the scorebot file.

Signal handler is unsupported
Attempting WebSocket connection to wss://scorebot-lb.hltv.org/socket.io/?transport=websocket&EIO=4
WebSocket connection accepted with {'sid': 'a60e8fb7-0da1-4394-9af2-d52894bd8887', 'upgrades': ['websocket'], 'pingInterval': 25000, 'pingTimeout': 60000}
Engine.IO connection established
Sending packet MESSAGE data 0{}
Received packet MESSAGE data 0
Namespace / is connected
Emitting event "readyForMatch" [/]
Sending packet MESSAGE data 2["readyForMatch","{\"listId\": 2354815}"]
connected to match 2354815!
running in background
Received packet MESSAGE data 4{},"Invalid namespace"
Task exception was never retrieved
future: <Task finished name='Task-14' coro=<AsyncClient._handle_eio_message() done, defined at C:\Python\Python39\lib\site-packages\socketio\asyncio_client.py:505> exception=JSONDecodeError('Extra data: line 1 column 3 (char 2)')>
Traceback (most recent call last):
  File "C:\Python\Python39\lib\site-packages\socketio\asyncio_client.py", line 516, in _handle_eio_message
    pkt = self.packet_class(encoded_packet=data)
  File "C:\Python\Python39\lib\site-packages\socketio\packet.py", line 43, in __init__
    self.attachment_count = self.decode(encoded_packet) or 0
  File "C:\Python\Python39\lib\site-packages\socketio\packet.py", line 128, in decode
    self.data = self.json.loads(ep)
  File "C:\Python\Python39\lib\site-packages\engineio\json.py", line 16, in loads
    return original_loads(*args, **kwargs)
  File "C:\Python\Python39\lib\json\__init__.py", line 359, in loads
    return cls(**kw).decode(s)
  File "C:\Python\Python39\lib\json\decoder.py", line 340, in decode
    raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 1 column 3 (char 2)
bombsimon commented 2 years ago

What code are you using to reproduce this? If I'm running the code in the example directory it seems to work as intended.

Are you using the environment from the Pipenv file locked to the exact versions of socketio?

samayala22 commented 2 years ago

Hey, sorry for the late response, was busy all week.

Yeah when using socketio version 5.4.0 I don't get the error anymore. However, another breaking error appeared.

Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x00000291E69F61F0>
Traceback (most recent call last):
  File "C:\Python\Python39\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Python\Python39\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon
    self._check_closed()
  File "C:\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x00000291E750DA00>

I'll try to find the event that triggers it.

bombsimon commented 2 years ago

No worries!

Right, I see that I've configured the Pipefile with a minimum version but no max version. I should lock that to a version that runs for me.

Double checking again, is this reproducible with the code in the example directory?

Feel free to file a PR if you figure out what the issue is!