-
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
reconnection only works if the server disconnected for few seconds not for a minute and above. #248
Comments
weird xD its working fine right now xD yesterday it dint. 🤯 like the test yesterday is consistent.. sorry about it :( one last thing before I close this issue.. if I expect the server to be offline after I start client..
is it ok by design to do this? call the main again. to ignore the error above? use rust_socketio::{ClientBuilder, Payload, RawClient};
use serde_json::json;
use std::io;
fn main() {
let callback = |payload: Payload, socket: RawClient| {
match payload {
Payload::String(str) => println!("Received: {}", str),
Payload::Binary(bin_data) => println!("Received bytes: {:#?}", bin_data),
}
socket
.emit("test", json!({"got ack": true}))
.expect("Server unreachable")
};
// get a socket that is connected to the admin namespace
let test = ClientBuilder::new("http://localhost:3000")
.namespace("/")
.on("test", callback)
.on("error", |err, _| {
eprintln!("Error: {:#?}", err);
})
.connect();
if test.is_err() {
println!("rc");
main();
}
io::stdin().read_line(&mut String::new()).unwrap();
} tbh im not really good at rust im a c++xD i just really wanna convert the client I made from using this https://github.com/socketio/socket.io-client-cpp but in rust.. because I find rust very interesting. |
As the socketio doc said https://socket.io/docs/v3/client-socket-instance/, first time connect failed will not reconnect, must be manual reconnect, reconnect should only after previous connect is succeed. |
Yes, this is definitely not the intended behavior! If the server is not available you should be notified and not try to reconnect forever!! |
aight thank you I will do manual reconnect. I think I'm in the wrong here and confused and I'm sorry xD haha I've never really use the real client of socket.io.. but instead I use this .. #angular (web) both of them will still reconnect even tho the server is not up xD because of that I assume that's the same behavior's across all client.. again sorry xD my bad.. I dint read the lifecycle on the real socket.io client and you guys are right base on lifecycle image of socket.io client it should not do this xD I just get confused i thought its the same behavior for all clients my bad. aight im gonna close this up. |
it do nothing. when I try turn off server for 15 seconds. I tried to do
.reconnect(true)
.max_reconnect_attempts(0)
also and thereconnect_delay(3, 5)
maybe it helps. it dint.btw what I mean by "not working is" well its doing nothing no error what so ever. I know it dint reconnect because server dint log the client socket id at
connection
event. and client surely dint receive theemit test
I send to any client that successfully pass theconnection
event.if I turn off/on server quick seconds again and again.. that's fine.. the reconnection is working chief kiss <3.. but when its longer than that.. 15s+. it doesn't do anything.
I really like the socket client JS behavior's that it keeps reconnecting no matter what happen like u will get a lot of xD connection error at console. like it keeps knocking to the door or hitting the door bell until server responded back.
help me out maybe I'm missing something.
also I realize auto reconnect only covers the part where you got disconnected not when u failed to connect on 1st run.
The text was updated successfully, but these errors were encountered: