-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
client don't try reconnect #169
Comments
Remove reconnect=5 from the example. |
Hi, I guess you're using TCP does know about reconnections. Once the channel is closed by one side (i.e, when you kill the server), the connection is considered closed for the other endpoint. If you want a reconnection mechanism, you should implement this on top of |
The way I got around this is to have the handler instantiation and e.g. the below will just wait 5 seconds, then try to reconnect loop {
let (handler, listener) = node::split::<()>();
let server = handler.network().connect(...)?;
listener.for_each(move |event| match event {
NodeEvent::Network(net_event) => match net_event {
NetEvent::Disconnected(_endpoint) => {
// do anything you want to do before exiting the listener...
handler.stop();
}
_ => {}
}
});
// at this point, the client has disconnected, so do anything you want to do such as waiting a few seconds before reconnecting...
std::thread::sleep(std::time::Duration::from_secs(5));
} That way you can easily implement your own re-connection logic (exponential fallback, max # of retries etc.) |
Thanks for your solution! In addition to the above answer, you can also use signals with a timer ( |
hi,
I run ping pong example, first run server and then run client, all is ok.
I kill server, and run server again, client don't try reconnect.
I hope client will try reconnect if network is disconnect.
The text was updated successfully, but these errors were encountered: