housleyjk / ws-rs

Lightweight, event-driven WebSockets for Rust.
MIT License
1.47k stars 222 forks source link

Client connection does not fully close #275

Open cfal opened 5 years ago

cfal commented 5 years ago

Even after closing a connection, messages can still be received.

This can be reproduced with the provided example by adding out.close(ws::CloseCode::Normal) after this line: https://github.com/housleyjk/ws-rs/blob/master/examples/server.rs#L20

After out.close, send() messages are no longer sent to the client but on_message is still triggered when the client sends a message.

Apologies if I'm missing something. Is there some way to fully close the connection?

cfal commented 5 years ago

I ended up modifying Connection to shutdown the socket in send_close which stopped messages from arriving: https://github.com/cfal/ws-rs/commit/3cc5cbf8cc1cf87e0f7379e3afc179e2cadf9c8d

Wondering if this was due to the client ignoring the close frame. FYI I was testing with https://github.com/vi/websocat via websocat ws://127.0.0.1:3012.