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

How to get notification when a client closes a Websocket connection? #211

Open
teddynecsoiu opened this issue Mar 10, 2022 · 3 comments
Open

Comments

@teddynecsoiu
Copy link

Basically what the title says.

If the client closes the connection, Dream.send fails with dream.log ERROR REQ 1 Async exception: (Failure "cannot write to closed writer").

Currently, I'm catching the exception but, preferably, there should be a cleaner way since this a generic exception.

@aantron
Copy link
Owner

aantron commented Mar 30, 2022

Reporting for now: I was able to reproduce this a couple weeks ago, but ran out of time to properly precisely diagnose it. I will get back to it in the near future.

@rizo
Copy link

rizo commented May 3, 2022

@aantron Hey! 👋 I'm running into a situation where knowing that a client closed a ws connection is critical to implement a product feature. My current approach is to store references to websocket values (and use ~close:false) and later try to close when Dream.send raises an exception (as described/assumed above). Unfortunately this seems to result in broken pipes.

Do you have any pointers to where would be the best place to start implementing notification for client termination in Dream? Happy to give it a shot, if you haven't looked into this yet.

@rizo
Copy link

rizo commented May 3, 2022

I think at the very least if would be useful to be able to run a clean up function potentially registered with Dream.websocket ~on_close.

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

No branches or pull requests

3 participants