>pip show python-socketio
Name: python-socketio
Version: 4.6.0
Summary: Socket.IO server
Home-page: http://github.com/miguelgrinberg/python-socketio/
Author: Miguel Grinberg
Author-email: miguelgrinberg50@gmail.com
License: MIT
Location: c:\python38\lib\site-packages
Requires: six, python-engineio
Required-by:
>pip show python-engineio
Name: python-engineio
Version: 3.13.1
Summary: Engine.IO server
Home-page: http://github.com/miguelgrinberg/python-engineio/
Author: Miguel Grinberg
Author-email: miguelgrinberg50@gmail.com
License: MIT
Location: c:\python38\lib\site-packages
Requires: six
Required-by: python-socketio
>python main.py
23:37:40.891.263, client, INFO, Attempting WebSocket connection to wss://ws.upstox.com/socket.io/? information removed &transport=websocket&EIO=3
23:37:41.931.590, client, INFO, WebSocket connection accepted with {'sid': 'AKfyGHnlpuv_91ZTAJFS', 'upgrades': [], 'pingInterval': 2000, 'pingTimeout': 60000}
23:37:41.931.590, client, INFO, Engine.IO connection established
23:37:41.932.587, client, INFO, Sending packet PING data None
23:37:41.942.563, client, INFO, Received packet MESSAGE data 0
23:37:41.943.559, client, INFO, Namespace / is connected
23:37:42.160.441, client, INFO, Received packet PONG data None
23:37:43.934.515, client, INFO, Sending packet PING data None
23:37:44.163.661, client, INFO, Received packet PONG data None
23:37:45.935.990, client, INFO, Sending packet PING data None
23:37:46.164.545, client, INFO, Received packet PONG data None
23:37:47.936.101, client, INFO, Sending packet PING data None
23:37:48.168.060, client, INFO, Received packet PONG data None
23:37:49.936.557, client, INFO, Sending packet PING data None
23:37:50.165.909, client, INFO, Received packet PONG data None
23:37:51.936.624, client, INFO, Sending packet PING data None
23:37:51.944.657, broker, INFO, Logging in to upstox server
23:37:51.944.657, client, INFO, Emitting event "message" [/]
23:37:51.944.657, client, INFO, Sending packet MESSAGE data 2["message",{"method":"client_login","type":"interactive","data":{"client_id":"","password":""}}]
23:37:52.170.459, client, INFO, Received packet PONG data None
23:37:52.222.219, client, INFO, Received packet MESSAGE data 2["message",{"timestamp":1610734070921,"response_type":"client_login","guid":null,"data":{"success":true,"statusCode":1,"connected_server":"ip-172-31-21-200"}}]
23:37:52.223.191, client, INFO, Received event "message" [/]
23:37:52.223.191, client, INFO, Emitting event "message" [/]
23:37:56.175.874, client, INFO, Received packet PONG data None
23:37:57.939.303, client, INFO, Sending packet PING data None
23:37:58.180.645, client, INFO, Received packet PONG data None
23:37:59.939.735, client, INFO, Sending packet PING data None
23:38:00.166.902, client, INFO, Received packet PONG data None
23:38:01.940.612, client, INFO, Sending packet PING data None
23:38:02.169.766, client, INFO, Received packet PONG data None
23:38:03.940.732, client, INFO, Sending packet PING data None
23:38:04.180.604, client, INFO, Received packet PONG data None
23:38:05.941.043, client, INFO, Sending packet PING data None
23:38:06.169.315, client, INFO, Received packet PONG data None
23:38:07.941.815, client, INFO, Sending packet PING data None
23:38:08.170.819, client, INFO, Received packet PONG data None
23:38:09.942.222, client, INFO, Sending packet PING data None
23:38:10.171.609, client, INFO, Received packet PONG data None
23:38:11.942.829, client, INFO, Sending packet PING data None
23:38:12.172.043, client, INFO, Received packet PONG data None
23:38:13.943.691, client, INFO, Sending packet PING data None
Uninstalled both and installed latest version of both. python-socketio = 5.0.4 python-engineio = 4.0.0
>pip uninstall python-engineio
Found existing installation: python-engineio 3.13.1
Uninstalling python-engineio-3.13.1:
Would remove:
c:\python38\lib\site-packages\engineio\*
c:\python38\lib\site-packages\python_engineio-3.13.1.dist-info\*
Proceed (y/n)? y
Successfully uninstalled python-engineio-3.13.1
>pip uninstall python-socketio
Found existing installation: python-socketio 4.6.0
Uninstalling python-socketio-4.6.0:
Would remove:
c:\python38\lib\site-packages\python_socketio-4.6.0.dist-info\*
c:\python38\lib\site-packages\socketio\*
Proceed (y/n)? y
Successfully uninstalled python-socketio-4.6.0
>pip install python-socketio
Collecting python-socketio
Using cached python_socketio-5.0.4-py2.py3-none-any.whl (52 kB)
Requirement already satisfied: bidict>=0.21.0 in c:\python38\lib\site-packages (from python-socketio) (0.21.2)
Collecting python-engineio>=4
Using cached python_engineio-4.0.0-py2.py3-none-any.whl (50 kB)
Installing collected packages: python-engineio, python-socketio
Successfully installed python-engineio-4.0.0 python-socketio-5.0.4
>python main.py
23:42:35.111.527, client, INFO, Attempting WebSocket connection to wss://ws.upstox.com/socket.io/? Information removed &transport=websocket&EIO=4
23:42:36.158.799, client, INFO, WebSocket connection accepted with {'sid': 'xzIaRZIKYz1BwKKkAJEw', 'upgrades': [], 'pingInterval': 2000, 'pingTimeout': 60000}
23:42:36.158.799, client, INFO, Engine.IO connection established
23:42:36.158.799, client, INFO, Sending packet MESSAGE data 0
23:42:36.184.729, client, INFO, Received packet MESSAGE data 0
23:42:36.185.752, client, INFO, Namespace / is connected
23:42:36.390.209, client, INFO, Received packet MESSAGE data 4"{\"timestamp\":1610734355081,\"response_type\":\"server_error\",\"error\":{\"message\":\"You have not been authorized for this action\",\"statusCode\":500}}"
23:42:36.395.195, client, INFO, Connection to namespace / was rejected
Exception in thread Thread-3:
Traceback (most recent call last):
File "C:\Python38\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Python38\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Python38\lib\site-packages\socketio\client.py", line 611, in _handle_eio_message
self._handle_connect(pkt.namespace, pkt.data)
File "C:\Python38\lib\site-packages\socketio\client.py", line 485, in _handle_connect
self._trigger_event('connect', namespace=namespace)
File "C:\Python38\lib\site-packages\socketio\client.py", line 547, in _trigger_event
return self.handlers[namespace][event](*args)
File "D:\projects\PTrade\broker_upstox_hacked\broker.py", line 205, in __login_to_upstox_server
self.__sio.send(loginJSON)
File "C:\Python38\lib\site-packages\socketio\client.py", line 364, in send
self.emit('message', data=data, namespace=namespace,
File "C:\Python38\lib\site-packages\socketio\client.py", line 328, in emit
raise exceptions.BadNamespaceError(
socketio.exceptions.BadNamespaceError: / is not a connected namespace.
23:43:36.157.881, client, WARNING, WebSocket connection was closed, aborting
23:43:36.158.879, client, INFO, Waiting for write loop task to end
23:43:36.158.879, client, INFO, Exiting write loop task
23:43:36.160.875, client, INFO, Engine.IO connection dropped
23:43:36.161.870, client, INFO, Exiting read loop task
In both client code is same, server is same only difference is socketio and enginio libraries.
Please let me know what I'm doing wrong or how to tackle this.
pythons-socketio version 4.6.0 & engineio version 3.13.1Connects and works perfectly withtout any problem.
Note:
Namespace / is connectedand no rejection from server sideVersion information of socketio & engineio
logging enabled in both library
Uninstalled both and installed latest version of both.
python-socketio = 5.0.4python-engineio = 4.0.0Latest library connects, but server sending
namespace / was rejected message, eventually leading to BadNamespaceError \ errorpython-socketio = 5.0.4python-engineio = 4.0.0In both client code is same, server is same only difference is socketio and enginio libraries.
Please let me know what I'm doing wrong or how to tackle this.