Can nginx interface with SocketIO using a unix socket #1602
Replies: 10 comments
-
I would think a unix socket should work exactly as a TCP/IP socket. |
Beta Was this translation helpful? Give feedback.
-
Yes thanks, I agree but I don't see how a SocketIO instance can be instantiated using a unix socket. I'm invoking with: socketio.run(app, debug=True, use_reloader=False, host='unix:///tmp/kzsuwww.sock') and because eventlet expects a traditional host & port using a socket value for host results in the following exception: Traceback (most recent call last): Any pointers you could provide as to how I can invoke this with a unix socket would be much appreciated. |
Beta Was this translation helpful? Give feedback.
-
Closing, the Abrahamsen example uses greenlet which does support Unix sockets. I was using eventlet which as far as I can tell cannot be configured to use them. |
Beta Was this translation helpful? Give feedback.
-
I think you are confusing the implementation of the Your |
Beta Was this translation helpful? Give feedback.
-
What do you think of modifying socketio.run() to accept a Unix socket? This would allow users to use the documented startup flow with a Unix socket. I can submit a PR for this if you are interested in such a change. |
Beta Was this translation helpful? Give feedback.
-
I'm okay with adding that. But you'll need to implement it for all the servers that |
Beta Was this translation helpful? Give feedback.
-
Can you clarify uwsgi based SocketIO case outlined in the uWSGI Web Server section of the documentation? When using this approach should I use the traditional app.run() invocation or would I still wrap it with the SocketIO.run() variant? I ask because with the former I get the "You need to use the eventlet server..." startup exception and in the latter I get an "Address already in use" error. Our current deployment uses nginx with multiple uwsgi processes and I'd like to preserve this architecture if possible. Any advice or examples you could provide for doing this would be much appreciated. |
Beta Was this translation helpful? Give feedback.
-
@eric-gilbertson I'm confused about your question. When you use uWSGI you run the uWSGI web server directly, so neither |
Beta Was this translation helpful? Give feedback.
-
Sorry, never mind that my 'run() comments, they are indeed not run when using usgi. The issue I don't get is how to invoke the eventlet server from within my app's startup code so that I don't get the 'You need to use the eventlet server. ' startup exception, e.g. does it matter what port it listens at? Should I model the invocation after the eventlet startup code in SocketIO's init.py? Also, if my socket IO load is low would it be okay to instantiate only a single instance of it when starting the master uwgi process or should each child also have one? Again, any examples or advice you can provide is much appreciated. - Eric |
Beta Was this translation helpful? Give feedback.
-
uWSGI does not work with eventlet. What are you setting |
Beta Was this translation helpful? Give feedback.
-
I am trying to configure Nginx to communicate with Flask-SocketIO via a Unix socket as outlined in the link below but the Nginx WS requests to uwsgi always time out. I would like to use this approach, if possible, because of the it seems that it would simplify deployment of multiple uwsgi's since it would not require allocation of instance specific ports as outlined in the 'Using nginx as a WebSocket Reverse Proxy' of the Flask-SocketIO documentation. I would appreciate it if you could comment as to whether Abrahmasen's should work and whether it would be a good approach for deploying multiple uwsgi instances under nginx?
Thank you very much for your great library and the comprehensive documentation.
https://michaelabrahamsen.com/posts/configuring-uwsgi-and-nginx-for-use-with-flask-socketio
Beta Was this translation helpful? Give feedback.
All reactions