Skip to content

Commit 2f085b3

Browse files
Document WebSocket support for threading mode
1 parent 0cc35ce commit 2f085b3

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

docs/server.rst

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Socket.IO servers to integrate easily into existing WSGI or ASGI applications::
5959
Serving Static Files
6060
--------------------
6161

62-
The Engine.IO server can be configured to serve static files to clients. This
62+
The Socket.IO server can be configured to serve static files to clients. This
6363
is particularly useful to deliver HTML, CSS and JavaScript files to clients
6464
when this package is used without a companion web framework.
6565

@@ -832,8 +832,7 @@ Standard Threads
832832
While not comparable to eventlet and gevent in terms of performance,
833833
the Socket.IO server can also be configured to work with multi-threaded web
834834
servers that use standard Python threads. This is an ideal setup to use with
835-
development servers such as `Werkzeug <http://werkzeug.pocoo.org>`_. Only the
836-
long-polling transport is currently available when using standard threads.
835+
development servers such as `Werkzeug <http://werkzeug.pocoo.org>`_.
837836

838837
Instances of class ``socketio.Server`` will automatically use the threading
839838
mode if neither eventlet nor gevent are not installed. To request the
@@ -854,15 +853,22 @@ development web server based on Werkzeug::
854853
# ... Socket.IO and Flask handler functions ...
855854

856855
if __name__ == '__main__':
857-
app.run(threaded=True)
856+
app.run()
857+
858+
The example that follows shows how to start an Socket.IO application using
859+
Gunicorn's threaded worker class::
860+
861+
$ gunicorn -w 1 --threads 100 module:app
858862

859-
When using the threading mode, it is important to ensure that the WSGI server
860-
can handle multiple concurrent requests using threads, since a client can have
861-
up to two outstanding requests at any given time. The Werkzeug server is
862-
single-threaded by default, so the ``threaded=True`` option is required.
863+
With the above configuration the server will be able to handle up to 100
864+
concurrent clients.
863865

864-
Note that servers that use worker processes instead of threads, such as
865-
gunicorn, do not support a Socket.IO server configured in threading mode.
866+
When using standard threads, WebSocket is supported through the
867+
`simple-websocket <https://github.com/miguelgrinberg/simple-websocket>`_
868+
package, which must be installed separately. This package provides a
869+
multi-threaded WebSocket server that is compatible with Werkzeug and Gunicorn's
870+
threaded worker. Other multi-threaded web servers are not supported and will
871+
not enable the WebSocket transport.
866872

867873
Scalability Notes
868874
~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)