Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tornado.websocket.WebSocketClosedError #251

Open
sansal54 opened this issue Aug 29, 2021 · 4 comments
Open

tornado.websocket.WebSocketClosedError #251

sansal54 opened this issue Aug 29, 2021 · 4 comments

Comments

@sansal54
Copy link

When I change something in code pages, I get following error 👍

Traceback (most recent call last):
  File "/root/.local/share/virtualenvs/cafe_app19-P_30WATA/lib/python3.8/site-packages/tornado/websocket.py", line 1104, in wrapper
    raise WebSocketClosedError()
tornado.websocket.WebSocketClosedError

I run my flask web app with :

sudo pipenv run python3 main.py

and my code for the server start is :

if __name__ == "__main__":
	# for hot reload during development, debug must be True.
	app.debug = True
	# Reload webpages on changes, without hitting refresh in your browser.
	server = Server(app.wsgi_app)
	server.serve(port=5000, host='localhost')
@KrustyHack
Copy link

Ay,

Same here with a Django app :

[I 210926 17:22:27 handlers:92] Reload 1 waiters: application/views.py
[W 210926 17:22:27 iostream:983] Write error on <socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6>: [Errno 9] Bad file descriptor
Task exception was never retrieved
future: <Task finished name='Task-10' coro=<WebSocketProtocol13.write_message.<locals>.wrapper() done, defined at /home/krustyhack/anaconda3/envs/xxx/lib/python3.8/site-packages/tornado/websocket.py:1100> exception=WebSocketClosedError()>
Traceback (most recent call last):
  File "/home/krustyhack/anaconda3/envs/xxx/lib/python3.8/site-packages/tornado/websocket.py", line 1102, in wrapper
    await fut
tornado.iostream.StreamClosedError: Stream is closed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/krustyhack/anaconda3/envs/xxx/lib/python3.8/site-packages/tornado/websocket.py", line 1104, in wrapper
    raise WebSocketClosedError()
tornado.websocket.WebSocketClosedError

But it works well when I only edit my HTML templates :

python manage.py livereload
[I 210926 17:26:17 server:335] Serving on http://127.0.0.1:8000
[I 210926 17:26:17 handlers:62] Start watching changes
[I 210926 17:26:17 handlers:64] Start detecting changes
[I 210926 17:26:26 handlers:135] Browser Connected: http://127.0.0.1:8000/
[I 210926 17:26:30 handlers:92] Reload 1 waiters: application/templates/application/index.html
[I 210926 17:26:30 handlers:135] Browser Connected: http://127.0.0.1:8000/
[I 210926 17:26:35 handlers:92] Reload 1 waiters: application/templates/application/index.html
[I 210926 17:26:35 handlers:135] Browser Connected: http://127.0.0.1:8000/

@Exordio
Copy link

Exordio commented Jun 29, 2022

Same in flask.

[W 220629 18:34:21 iostream:983] Write error on <socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=2049, proto=6>: [Errno 9] Bad file descriptor
Task exception was never retrieved
future: <Task finished coro=<WebSocketProtocol13.write_message.<locals>.wrapper() done, defined at /home/xxx/workspace/xxx/venv/lib64/python3.6/site-packages/tornado/websocket.py:1100> exception=WebSocketClosedError()>
Traceback (most recent call last):
  File "/home/xxx/workspace/xxx/venv/lib64/python3.6/site-packages/tornado/websocket.py", line 1102, in wrapper
    await fut
tornado.iostream.StreamClosedError: Stream is closed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/xxx/workspace/xxx/venv/lib64/python3.6/site-packages/tornado/websocket.py", line 1104, in wrapper
    raise WebSocketClosedError()
tornado.websocket.WebSocketClosedError

@Prinzhorn
Copy link

Might be an upstream race condition with on_close being called before on_message, so it's not removed from the waiters

def on_close(self):
if self in LiveReloadHandler.waiters:
LiveReloadHandler.waiters.remove(self)

tornadoweb/tornado#2958

@cuongtv51
Copy link

cuongtv51 commented Jul 19, 2024

any update for this bug, i have same problem here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants