I am trying to use flask socket.io in docker with basic commands.
When i am running single worker of gunicorn everything is working fine but when i increase the workers, then on the client side it start giving 400 Bad Request and on server logs i see Invalid session lWmxdNRmai59bRfLAAAA (further occurrences of this error will be logged with level INFO).
these are the commands i am using gunicorn --worker-class geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 2 application:app -b 0.0.0.0:5000
and application.py file is
from gevent import monkey monkey.patch_all()
from flask import Flask from flask_socketio import SocketIO from flask import session
app = Flask(__name__)
app.config.from_object("settings.BaseConfig")
socket_app = SocketIO(
app,
cors_allowed_origins="*",
message_queue=settings.get_evn("CACHE_QUEUE_URL"),
async_mode="gevent",
)
socket_app.init_app(app, cors_allowed_origins="*")
I am using redis for message queue and have verified that the messaging queue url is correct
using aws load balancer for serving the request
Multiple gunicorn workers aren't supported because the Gunicorn load balancing algorithm is incompatible with Socket.IO requirements.
From the documentation: