Sanic: anyone using python-socketio with sanic?

Created on 27 Jan 2017  ·  5Comments  ·  Source: sanic-org/sanic

Hi, i'm sorry that this is not even a issue. i was wondering if anyone has tried http://python-socketio.readthedocs.io/en/latest/ with sanic.

question

Most helpful comment

Author of python-socketio here. I have recently added support for asyncio, and have implemented integrations for aiohttp and sanic. The aiohttp integration supports long-polling and websocket. Sanic only supports long-polling.

Here are a couple of examples for sanic: https://github.com/miguelgrinberg/python-socketio/tree/master/examples/sanic.

All 5 comments

I don't think that library is asyncio. For asyncio WebSockets, you might want to look at:

https://websockets.readthedocs.io/en/stable/

There's some interest in creating a sanic extension for web sockets in issue #12.

closing in favor of #12

Author of python-socketio here. I have recently added support for asyncio, and have implemented integrations for aiohttp and sanic. The aiohttp integration supports long-polling and websocket. Sanic only supports long-polling.

Here are a couple of examples for sanic: https://github.com/miguelgrinberg/python-socketio/tree/master/examples/sanic.

@miguelgrinberg I tried to use sanic with socketio, but whenever I try to start sanic with multiple workers, the socket crashes and no connection is made! what is the solution?

You need to use a single worker process. The SocketIO is a stateful service, it cannot work with multiple workers. The alternative is to start several single-process servers, and put them behind a reverse proxy such as nginx configured with sticky sessions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jasonab picture jasonab  ·  3Comments

woutor picture woutor  ·  3Comments

1067511899 picture 1067511899  ·  3Comments

sirex picture sirex  ·  4Comments

misakar picture misakar  ·  4Comments