AtherEnergy / rumqtt

Pure rust mqtt cilent
The Unlicense
202 stars 71 forks source link

Network Thread Stopped after several broker restarts #95

Closed tomasol closed 6 years ago

tomasol commented 6 years ago

I have automatic reconnection set, but after randmly restarting mqtt broker I have seen:

RROR 2018-10-24T12:59:57Z: rumqtt::connection:   Will try Reconnect in 3 seconds
 INFO 2018-10-24T13:00:00Z: rumqtt::connection: $$$ Connected to broker
DEBUG 2018-10-24T13:00:00Z: rumqtt::connection: *** Force Retransmission. Publish Queue =
[]

DEBUG 2018-10-24T13:00:00Z: rumqtt::connection: *** Force Retransmission. Record Queue =
[]

ERROR 2018-10-24T13:00:04Z: rumqtt::connection: At line 214 = Error in receiving packet Custom { kind: Other, error: StringError("unexpected EOF") }
ERROR 2018-10-24T13:00:04Z: rumqtt::connection:   Disconnected Some("123")
ERROR 2018-10-24T13:00:07Z: rumqtt::client: Network Thread Stopped !!!!!!!!!

I've modified start function in client.rs:

        thread::spawn(move || -> Result<()> {
            loop {
                let result = connection.run();
                error!("Network Thread Stopped: {:?}", result);
                if connection.dont_reconnect {
                    break;
                }
            }
            Ok(())
        });

and the result is Err(InvalidPacket). With the workaround the client will not die and continues to reconnect. Not sure where that comes from.

tomasol commented 6 years ago

Note that I am running a slightly modified version of your lib: https://github.com/tomasol/rumqtt/tree/12c5ba661571115c5cdc7bb2590f2411893ea394 , but changes were only made for sending puback after on_message callback ( #94 ). Another note: I would suggest adding reconnect strategy even if MqttClient::start fails to connect first time.

tekjar commented 6 years ago

Thanks for the report @tomasol. Unfortunately I don't have the bandwidth to verify/fix this. I just pushed a work in progress v3 branch. Can you give a shot to that?

tekjar commented 6 years ago

Please reopen this if you are facing issues with the new master branch