Replies: 3 comments
-
I'm not sure if the reason is the root. I tried to change uid and gid to uwsgi (a new user I created): [uwsgi]
http = :8000
http-websockets = true
master = true
gevent = 1000
wsgi-file = app.py
callable = app
processes = 1
threads = 1
buffer-size = 32768
; logto = ./logs/flask-test-uwsgi.logs
uid=uwsgi
gid=uwsgi
gevent-monkey-patch = true
log-format = %(addr) - %(method) %(uri) => generated %(size) bytes in %(msecs) ms But the output is same: root@static-websites-server:/opt/flask-test# uwsgi --ini flask-test-uwsgi.ini
[uWSGI] getting INI configuration from flask-test-uwsgi.ini
*** Starting uWSGI 2.0.26 (64bit) on [Sun Jun 23 04:36:30 2024] ***
compiled with version: 11.4.0 on 23 June 2024 03:55:12
os: Linux-5.15.0-92-generic #102-Ubuntu SMP Wed Jan 10 09:33:48 UTC 2024
nodename: static-websites-server
machine: x86_64
clock source: unix
detected number of CPU cores: 4
current working directory: /opt/flask-test
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
setgid() to 123
setuid() to 116
your processes number limit is 63801
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
- async cores set to 1000 - fd table size: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on :8000 fd 4
uwsgi socket 0 bound to TCP address 127.0.0.1:40361 (port auto-assigned) fd 3
Python version: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
Python main interpreter initialized at 0x55dde5713b90
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 78380928 bytes (76543 KB) for 1000 cores
*** Operational MODE: async ***
WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x55dde5713b90 pid: 384057 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 384057)
spawned uWSGI worker 1 (pid: 384063, cores: 1000)
spawned uWSGI http 1 (pid: 384064)
*** running gevent loop engine [addr:0x55dde3c2d040] ***
127.0.0.1 - GET /socket.io/?transport=polling&EIO=4&t=1719117392.1000278 => generated 197 bytes in 1 ms
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1498, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python3.10/dist-packages/flask_socketio/__init__.py", line 43, in __call__
return super(_SocketIOMiddleware, self).__call__(environ,
File "/usr/local/lib/python3.10/dist-packages/engineio/middleware.py", line 63, in __call__
return self.engineio_app.handle_request(environ, start_response)
File "/usr/local/lib/python3.10/dist-packages/socketio/server.py", line 433, in handle_request
return self.eio.handle_request(environ, start_response)
File "/usr/local/lib/python3.10/dist-packages/engineio/server.py", line 274, in handle_request
packets = socket.handle_get_request(
File "/usr/local/lib/python3.10/dist-packages/engineio/socket.py", line 90, in handle_get_request
return getattr(self, '_upgrade_' + transport)(environ,
File "/usr/local/lib/python3.10/dist-packages/engineio/socket.py", line 146, in _upgrade_websocket
return ws(environ, start_response)
File "/usr/local/lib/python3.10/dist-packages/engineio/async_drivers/gevent.py", line 54, in __call__
raise RuntimeError('The gevent-websocket server is not '
RuntimeError: The gevent-websocket server is not configured appropriately. See the Deployment section of the documentation for more information.
127.0.0.1 - GET /socket.io/?transport=websocket&EIO=4&sid=5G_vJ_orT90hHpPeAAAA&t=1719117392.1035254 => generated 0 bytes in 29 ms
127.0.0.1 - POST /socket.io/?transport=polling&EIO=4&sid=5G_vJ_orT90hHpPeAAAA => generated 87 bytes in 0 ms
127.0.0.1 - GET /socket.io/?transport=polling&EIO=4&sid=5G_vJ_orT90hHpPeAAAA&t=1719117392.1347957 => generated 132 bytes in 0 ms
Received message: Hello from client!
127.0.0.1 - POST /socket.io/?transport=polling&EIO=4&sid=5G_vJ_orT90hHpPeAAAA => generated 87 bytes in 0 ms
127.0.0.1 - GET /socket.io/?transport=polling&EIO=4&sid=5G_vJ_orT90hHpPeAAAA&t=1719117392.137598 => generated 140 bytes in 0 ms |
Beta Was this translation helpful? Give feedback.
0 replies
-
For uWSGI you have to define your SocketIO server as follows: socketio = SocketIO(app, async_mode='gevent_uwsgi') |
Beta Was this translation helpful? Give feedback.
0 replies
-
@miguelgrinberg Thanks for your reply. I'll try it! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello:
I'm trying to use the flask-socketio with uWSGI and I get this error whenever I restart the client.
I found an old discussion about this: #1797 but he's using gunicorn.
My app.py:
client-uwsgi.py:
I tried the command is
uwsgi --http :8000 --gevent 1000 --http-websockets --master --wsgi-file app.py --callable app
Client output:
It seems like the client connected successfully but the uwsgi raise the error (uwsgi output):
Or using an uWSGI config file to start it:
But the result is same:
Beta Was this translation helpful? Give feedback.
All reactions