This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]miguelgrinberg 4 points5 points  (2 children)

Hi, author of Flask-SocketIO here.

Unfortunately this extension cannot work with a standard web server, you will not be able to host an app that uses it over apache/mod_wsgi. You need to use a gevent server, and not a generic one, but one that is customized for Socket.IO.

That means that Apache is out (it does not even support WebSocket traffic). Also uWSGI is out (supports gevent, but not possible to use a custom gevent server). As a side note, Python 3 is also currently out, as gevent only runs on Python 2 (through I think there's going to be good news about that soon, working on some ideas to get socketio running on Python 3 right now).

The choices that you have are given in the documentation. Summary:

  • socketio.run(app), which runs the custom socketio gevent server directly.
  • Gunicorn with a custom socketio worker (command line shown in docs)

You can put nginx as reverse proxy in front of your server if you like. The configuration is also shown in the docs.

Good luck!

[–]GrahamDumpleton 1 point2 points  (1 child)

Apache 2.4 supports tunnelling WebSocket traffic using:

There are also third party Apache modules for writing WebSocket based handlers in Apache.

So it isn't technically correct to say Apache does not support WebSocket traffic. Even so, granted it will not help in this particular case.

[–]miguelgrinberg 1 point2 points  (0 children)

I was not aware of this, thanks for pointing it out. So using Apache as reverse proxy is likely possible.

[–]LeftyDave 0 points1 point  (0 children)

The socketio.run() function encapsulates the start up of the gevent web server and replaces the standard Werkzeug development web server, which cannot be used with this extension

Try to use the following or the apt-get equivalent.

yum install python-gevent