flask-uwsgi-websocket
flask-uwsgi-websocket copied to clipboard
How can I fix this AsyncioWebSocket "RuntimeError: Event loop is closed" issue?
I setup a Flask instance using AsyncioWebSocket websockets and implemented the echo
example. It works completely fine, I can send and receive websocket messages just fine without any error messages on neither browser nor server side.
But if I leave it for a like 5-10 minutes and then load the echo
example again I get these error messages below all of a sudden.
How can I fix this issue?
{"datetime":"11/15/2017 15:54:34", "timestamp":1510732474548634, "msg":"Traceback (most recent call last):"}
{"datetime":"11/15/2017 15:54:34", "timestamp":1510732474549313, "msg":" File \"/var/www/testweb/venv/lib/python3.5/site-packages/flask/app.py\", line 1997, in __call__"}
{"datetime":"11/15/2017 15:54:34", "timestamp":1510732474551626, "msg":" return self.wsgi_app(environ, start_response)"}
{"datetime":"11/15/2017 15:54:34", "timestamp":1510732474552147, "msg":" File \"/var/www/testweb/venv/lib/python3.5/site-packages/flask_uwsgi_websocket/_asyncio.py\", line 122, in __call__"}
{"datetime":"11/15/2017 15:54:34", "timestamp":1510732474552939, "msg":" client = self.client(environ, uwsgi.connection_fd(), self.websocket.timeout, greenlet.getcurrent())"}
{"datetime":"11/15/2017 15:54:34", "timestamp":1510732474553487, "msg":" File \"/var/www/testweb/venv/lib/python3.5/site-packages/flask_uwsgi_websocket/_asyncio.py\", line 23, in __init__"}
{"datetime":"11/15/2017 15:54:34", "timestamp":1510732474554201, "msg":" self._loop.add_reader(self.fd, self._recv_ready)"}
{"datetime":"11/15/2017 15:54:34", "timestamp":1510732474554706, "msg":" File \"/usr/lib/python3.5/asyncio/selector_events.py\", line 231, in add_reader"}
{"datetime":"11/15/2017 15:54:34", "timestamp":1510732474555640, "msg":" self._check_closed()"}
{"datetime":"11/15/2017 15:54:34", "timestamp":1510732474556135, "msg":" File \"/usr/lib/python3.5/asyncio/base_events.py\", line 334, in _check_closed"}
{"datetime":"11/15/2017 15:54:34", "timestamp":1510732474557029, "msg":" raise RuntimeError('Event loop is closed')"}
{"datetime":"11/15/2017 15:54:34", "timestamp":1510732474557545, "msg":"RuntimeError: Event loop is closed"}