sdroege/async-tungstenite

Question: How should I go about sending close frames when my program is exiting?

ldesgoui opened this issue · 1 comments

Hello,

I have a small program serving long-lasting websockets, I'd like to cleanly close those when my program exits.
Right now, I just drop the stream and it causes the client to exit with Error 1006/EOF.
How would you suggest handling that?
It's not the end of the world if it remains that way, the server isn't exposed to the public, I'm just curious about what would be good practice

Thank you

You could send a Close message via the web socket to notify the other side the it's going to be closed. But simply closing the underlying TCP connection is also fine and should be handled accordingly.