You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've scoured the docs and haven't found a way to terminate a single connection between a ws Rust server and a client. I'm trying to do this from the server-side.
Sending a close message is nice when the client is still connected, but I am interested in handling the case when the client's network connection drops out. In this case, sending a close message won't actually close the connection because the client is disconnected and can't sent a response.
The ws library in Node.js provides ws.terminate() to forcibly terminate a connection with a client. Does the ws library in Rust have a similar method or some way to terminate a connection?
The text was updated successfully, but these errors were encountered:
In the ping-pong example, if I try to connect with this bad client that doesn't respond to pings, the connection will not be closed and the ping will go on until the connection is eventually dropped.
externcrate ws;use ws::{connect,Frame,CloseCode,Message,OpCode,Result};structClient{out: ws::Sender,}impl ws::HandlerforClient{fnon_frame(&mutself,frame:Frame) -> Result<Option<Frame>>{if frame.opcode() == OpCode::Ping{println!("Received a ping, but we are not responding");}Ok(None)}}fnmain(){connect("ws://127.0.0.1:8080", |out| {Client{out: out,}}).unwrap();}
I took a look at the Sender::shutdown() function, it basically loops through all the connections and terminates them. Is it possible to identify a particular connection (by Token maybe?) inside the connections array and add a new function to terminate only one?
I've scoured the docs and haven't found a way to terminate a single connection between a ws Rust server and a client. I'm trying to do this from the server-side.
Sending a close message is nice when the client is still connected, but I am interested in handling the case when the client's network connection drops out. In this case, sending a close message won't actually close the connection because the client is disconnected and can't sent a response.
The ws library in Node.js provides
ws.terminate()
to forcibly terminate a connection with a client. Does the ws library in Rust have a similar method or some way to terminate a connection?The text was updated successfully, but these errors were encountered: