tokio2: Disconnect after 1 minute #76
Comments
@dbrgn What is your keep alive time?. Can you send rumqtt debug logs |
Keep alive time is currently let client_options = MqttOptions::new(client_id, "eu.thethings.network:1883".to_string())
.unwrap_or_else(|e| {
println!("Could not initialize MqttOptions: {}", e);
exit(3);
})
.set_keep_alive(10)
.set_reconnect_opts(ReconnectOptions::AfterFirstSuccess(10))
.set_security_opts(SecurityOptions::UsernamePassword((
conf.ttn_app_id.clone(),
conf.ttn_access_key.clone(),
))); And here's the log:
(Btw, now I understand why the interval is not consistent - you're polling at 5s intervals :) That's probably fine though.) |
https://github.com/AtherEnergy/rumqtt/blob/tokio2/src/client/connection.rs#L181
Yeah, Interval to check if ping is required should be less than half the keepalive time to make sure that broker gets pingreq in 1.5 * keepalive time. I think this is right on the edge. Maybe I'll check at keepalive/3. Also I'm thinking not to allow keepalive less than 10 secs. But need some consensus on this |
I've tested with keep_alive = 30 and it works well :) |
When setting the keepalive to 60, I don't get those disconnects anymore. Regarding the intervals, since you use tokio, can't you use something like https://github.com/tokio-rs/tokio-timer to schedule the next ping message, instead of checking every 5s? |
@dbrgn I'm using reactor's In your case, when |
1 similar comment
@dbrgn I'm using reactor's In your case, when |
Ah, I wasn't aware that the broker has certain keepalive expectations. I looked at the spec yesterday, but in the area where the ping messages are specified there is no mention of that 🙂 Can't you just do an interval with the exact keepalive duration, and use |
@dbgrn Maybe we can use this to timeout when there is no activity |
Hm, isn't that to do asynchronous write/read operations with a timeout (must complete within a certain duration)? Would that help in this case? |
@dbrgn I think we can use |
Yeah, but even if you wrap a timeout around it, the reactor tries to complete the future as soon as possible, right? The timeout is only relevant if the future is blocking longer than the specified duration. |
Hi. Can you please test this with master branch and report back if it's still happening? Closing this for now |
I'm experiencing a disconnect from the server after a bit more than 1 minute.
Here's a wireshark trace:
(If required I can also send more details or a pcap file)
The ping messages are sent at t = 25, 35 (+10), 50 (+15), 60 (+10), 75 (+15). First of all, it seems a bit strange that the intervals are not consistent. Then, after sending the ping request at t=75, the connection is immediately closed by the server.
In the ping message itself I cannot find anything suspicious. There's no counter that could go out of sync or something like that, is there?
The text was updated successfully, but these errors were encountered: