@@ -215,23 +215,23 @@ Using a Message Queue
215215
216216The Socket.IO server owns the socket connections to all the clients, so it is
217217the only process that can emit events to them. Unfortunately this becomes a
218- limitation for many applications, as a common need is to emit events to
219- clients from a different process, like a
220- `Celery <http://www.celeryproject.org/ >`_ worker, or any other auxiliary
221- process or script that works in conjunction with the server.
218+ limitation for many applications that use more than one process. A common need
219+ is to emit events to clients from a process other than the server, for example
220+ a `Celery <http://www.celeryproject.org/ >`_ worker.
222221
223- To enable these other processes to emit events, the server can be configured
224- to listen for externally issued events on a message queue such as
222+ To enable these auxiliary processes to emit events, the server can be
223+ configured to listen for externally issued events on a message queue such as
225224`Redis <http://redis.io/ >`_ or `RabbitMQ <https://www.rabbitmq.com/ >`_.
226225Processes that need to emit events to client then post these events to the
227226queue.
228227
229228Another situation in which the use of a message queue is necessary is with
230229high traffic applications that work with large number of clients. To support
231230these clients, it may be necessary to horizontally scale the Socket.IO
232- server by splitting the client list among multiple server processes. For this
233- type of installation, the server processes communicate with each other through
234- ta message queue.
231+ server by splitting the client list among multiple server processes. In this
232+ type of installation, each server processes owns the connections to a subset
233+ of the clients. To make broadcasting work in this environment, the servers
234+ communicate with each other through the message queue.
235235
236236The message queue service needs to be installed and configured separately. By
237237default, the server uses `Kombu <http://kombu.readthedocs.org/en/latest/ >`_
@@ -240,29 +240,38 @@ can be used. Kombu can be installed with pip::
240240
241241 pip install kombu
242242
243+ To use RabbitMQ or other AMQP protocol compatible queues, that is the only
244+ required dependency. But for other message queues, Kombu may require
245+ additional packages. For example, to use a Redis queue, Kombu needs the Python
246+ package for Redis installed as well::
247+
248+ pip install redis
249+
243250To configure a Socket.IO server to connect to a message queue, the
244251``client_manager `` argument must be passed in the server creation. The
245252following example instructs the server to connect to a Redis service running
246253on the same host and on the default port::
247254
248- redis = socketio.KombuManager('redis://localhost:6379/ ')
255+ redis = socketio.KombuManager('redis://')
249256 sio = socketio.Server(client_manager=redis)
250257
251- For a RabbitMQ queue also running on the local server, the configuration is
252- as follows::
258+ For a RabbitMQ queue also running on the local server with default
259+ credentials, the configuration is as follows::
253260
254- amqp = socketio.KombuManager('amqp://guest:guest@localhost:5672// ')
261+ amqp = socketio.KombuManager('amqp://')
255262 sio = socketio.Server(client_manager=amqp)
256263
257264The arguments passed to the ``KombuManager `` constructor are passed directly
258265to Kombu's `Connection object
259- <http://kombu.readthedocs.org/en/latest/userguide/connections.html> `_.
266+ <http://kombu.readthedocs.org/en/latest/userguide/connections.html> `_, so
267+ the Kombu documentation should be consulted for information on how to
268+ connect to the message queue appropriately.
260269
261270If multiple Sokcet.IO servers are connected to a message queue, they
262- automatically communicate with each other and manage a combine client list,
271+ automatically communicate with each other and manage a combined client list,
263272without any need for additional configuration. To have a process other than
264273the server connect to the queue to emit a message, the same ``KombuManager ``
265- class can be used. For example::
274+ class can be used as standalone object . For example::
266275
267276 # connect to the redis queue
268277 redis = socketio.KombuManager('redis://localhost:6379/')
0 commit comments