SocketIO 400 Bad Request messages handling #1811
-
I use SocketIO_client ( 0.7.2) with Python3 to connect to Flask-SocketIO 4.3.1 server. When I run python client manually sometimes, I got warning messages from server : "WARNING:socketIO-client:xxxxxxxxxx/socket.io [connection error] unexpected status code (400 Bad Request)." And then emit doesn't work anymore.... When I run the same python program in background or as service the 400 Bad request is permanent and client can't receive message form server anymore. I noticed that when I install eventlet on client, the client hangs on connect and no can't connect to server. I need help to : Fix theses messages at server sides |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 11 replies
-
First of all, there is no need to spam all my projects with the question. One discussion is enough. Thank you. Second, I don't know if the old socketio_client package works well. This is a very old/outdated client. I recommend that you use the client that comes with python-socketio, which you already have installed since that package is a dependency of Flask-SocketIO. If you use the same version of python-socketio for the server and the client you should be fine, I think. |
Beta Was this translation helpful? Give feedback.
-
Hello, I installed new Falsk-Socketio (flask-socketio-5.1.1 python-socketio-5.5.2) but when trying to run the server have following errors: 10.2.3.144 - - [05/Apr/2022 19:18:17] "GET /socket.io/?transport=polling&EIO=4&t=1649186297.098767 HTTP/1.1" 200 - Please, could check the message and advise. Thanks. |
Beta Was this translation helpful? Give feedback.
-
Hello, Sorry for the silence. I was involved in an emergency. I found what was the problem : When a new client connect to the customized Namespace, the "on_connect" emit message ( I added an "emit" message to on_connect() of customized Namespace class on server...) is not received by new connected client but all other clients connected to the same Namespace receive that message. It's for that reason I thought the connection to the customized namespace failed but it succeed and others events and emit are received by client. If you could advise on why the emit of "on_connect" is not received by new connected client that could help... But it's no more my main issue. Thanks. |
Beta Was this translation helpful? Give feedback.
-
Hi, My new and urgent issue is:
"-" - - [22/Apr/2022:10:36:38 +0000] "POST /socket.io/?transport=polling&EIO=4&sid=StfVCRZ3BNgTCwn5AAAd HTTP/1.1" 400 17 "-" "python-requests/2.25.1" I have same message even when connection to server IP or through NGINX Proxy. I implemented server with gunicorn==20.1.0 and eventlet==0.30.2. Server code : from flask import Flask app = Flask(name) class MyNamespaceClass(Namespace):
socketio = SocketIO(app,logger=True, engineio_logger=True,cors_allowed_origins="*",async_mode='eventlet', ping_timeout=60) socketio.on_namespace(MyNamespaceClass('/Test')) if name == 'main': Client Code: import socketio class PMonitor(socketio.ClientNamespace):
sio = socketio.Client() Thanks for your availability and patience. Regards. |
Beta Was this translation helpful? Give feedback.
-
Also, more details: I doesn't have this problem when testing apps in local (by running apps by pyhton wsgi.py). The problem occur only when deployed on remote server with Gunicorn and gevent. Thanks. |
Beta Was this translation helpful? Give feedback.
-
Hello, You are right! I checked again and my bad was to trying to use multiple workers on single node. I changed workers=1 in gunicorn config file and it fixed all issues. You can clause this ticket right now please. Thanks. |
Beta Was this translation helpful? Give feedback.
First of all, there is no need to spam all my projects with the question. One discussion is enough. Thank you.
Second, I don't know if the old socketio_client package works well. This is a very old/outdated client. I recommend that you use the client that comes with python-socketio, which you already have installed since that package is a dependency of Flask-SocketIO. If you use the same version of python-socketio for the server and the client you should be fine, I think.