bonifaido / rust-zookeeper

Pure Rust library for Apache ZooKeeper built on MIO
MIT License
206 stars 46 forks source link

please let zookeeper io socket set tcp keepalive #92

Open Pabears opened 1 year ago

Pabears commented 1 year ago

We have found this issue when the router is down, and the zk server has sent RST, but the client has not received the RST because the router is down. so, the TCP status is ESTABLISHED but the zk session is totally down, and the client doesn't know it.

the Java codes look like:

import java.net.*; import org.apache.zookeeper.client.ZKClientConfig; import org.apache.zookeeper.ZooKeeper;

...

ZKClientConfig zkClientConfig = new ZKClientConfig(); zkClientConfig.setProperty(ZKClientConfig.ZOOKEEPER_SOCK_OPTS, "SO_KEEPALIVE=true"); ZooKeeper zk = new ZooKeeper("localhost:2181", 3000, null, zkClientConfig);

...

bonifaido commented 1 year ago

Sounds like a fair idea, if you have something already at hand pull-requests are more than welcome!

mati865 commented 1 year ago

net2 (and thus old mio) doesn't support KEEPALIVE so it'd require porting to socket2 and more recent mio.