Replies: 2 comments 1 reply
-
Hey @vovkman It's not included in v0.20.1 because it's a breaking change and ideally the intention is to provide some kind of middleware to decide when to close a connection instead of just a ping/pong timer. You can try it on master though |
Beta Was this translation helpful? Give feedback.
0 replies
-
Meanwhile, you could actually configure the async fn run_server() -> anyhow::Result<SocketAddr> {
use socket2::*;
let addr: SocketAddr = "127.0.0.1:9944".parse().unwrap();
let socket = Socket::new(Domain::IPV4, Type::STREAM, None).unwrap();
socket.set_nonblocking(true).unwrap();
socket.set_keepalive(true).unwrap();
let keepalive = socket2::TcpKeepalive::new().with_time(Duration::from_secs(4));
socket.set_tcp_keepalive(&keepalive).unwrap();
socket.bind(&addr.into()).unwrap();
socket.listen(4096).unwrap();
let listener: std::net::TcpListener = socket.into();
let server = Server::builder().build_from_tcp(listener).unwrap();
let mut module = RpcModule::new(());
module.register_method("say_hello", |_, _| "lo")?;
let addr = server.local_addr()?;
let handle = server.start(module);
// In this example we don't care about doing shutdown so let's it run forever.
// You may use the `ServerHandle` to shut it down or manage it yourself.
tokio::spawn(handle.stopped());
Ok(addr)
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there, curious if theres any way to close a websocket connection? I can't seem to find a way. It looks like a PR is coming in to terminate on inactivity, but seems like it didn't make it into 0.20.1 (even though it looks like it did?)
Beta Was this translation helpful? Give feedback.
All reactions