miguelgrinberg / python-socketio

Python Socket.IO server and client
MIT License
3.98k stars 587 forks source link

Raise Request Timeout Error with Sanic implementation #134

Closed MaxOvcharov closed 7 years ago

MaxOvcharov commented 7 years ago

We try to use Socket.io server with Sanic implementation. The connection is created fine but after 2 minutes server raised this error:

2017-09-01 09:54:41 - (sanic)[ERROR]: Traceback (most recent call last):
  File "/home/max/bot_project/mobile_mos_ru_backend/venv/lib/python3.5/site-packages/sanic/server.py", line 143, in connection_timeout
    raise RequestTimeout('Request Timeout')
sanic.exceptions.RequestTimeout: Request Timeout

We run our server using this code:

def main():
    options = parse_args_for_run_server()
    asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
    loop = asyncio.get_event_loop()
    app = loop.run_until_complete(init(loop))
    server = app.create_server(host=options.host, port=options.port, debug=False, log_config=None)
    asyncio.ensure_future(server)
    try:
        loop.run_forever()
    except KeyboardInterrupt:
        loop.run_until_complete(close_rd(sio.rd))
        loop.run_until_complete(close_pg(sio.pg))
        loop.run_until_complete(sio.amqp_producer.close_producer_conn())
        loop.stop()

Init Socket.io server:

sio = socketio.AsyncServer(async_mode='sanic', allow_upgrades=True)

There is an issue in Sanic repo. Is this the same problem?

MaxOvcharov commented 7 years ago

Now, it's works fine

jiaxiaolei commented 7 years ago

@MaxOvcharov What make it work well?

Just add debug=False, log_config=None? https://github.com/channelcat/sanic/issues/902