Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Paho » Send while disconnected not working when network disconnects(Using MQTT Async C library)
Send while disconnected not working when network disconnects [message #1810744] Mon, 19 August 2019 04:03 Go to next message
Shardul Rao is currently offline Shardul RaoFriend
Messages: 2
Registered: August 2019
Junior Member
I recently switched my Publisher from Sync to Async library to specifically use the sendWhileDisconncted option.

There are two ways I am testing this on Raspberry Pi.

1. Kill the broker and start again after few minutes
-- this use case seems to be working. The messages sent during those few minutes are NOT lost and received by the broker.

2. Disconnect the ethernet cable / restart the ISP router connected (RPi is connected to another Wifi router which is connected to ISP router)
-- this is not working. The message sent while the network is disconnected are lost -- not sent again.

The second scenario is crucial as that's what tends to happen in the field. The local router is fine, but the Service Provider disconnects.

In both cases the notification/callbacks for MQTT connect and disconnect are happening as expected. When using automaticReconnect instead of MQTTAsync_reconnect(), the behaviour is weird as only some of the messages are resent.

keepAliveInterval is set to 5, but I am sending a message every second.

Is there anything else I need to set perhaps on the RPi or MQTT settings to allow buffering of messages in second scenario?
Re: Send while disconnected not working when network disconnects [message #1810951 is a reply to message #1810744] Thu, 22 August 2019 15:40 Go to previous messageGo to next message
Ian Craggs is currently offline Ian CraggsFriend
Messages: 83
Registered: March 2013
Member
What QoS are you using? If 0, you should try 1 or 2. If the problem exists with 1 or 2, take a trace as outlined in the readme, and open an issue.
Re: Send while disconnected not working when network disconnects [message #1810960 is a reply to message #1810951] Thu, 22 August 2019 16:50 Go to previous message
Shardul Rao is currently offline Shardul RaoFriend
Messages: 2
Registered: August 2019
Junior Member
Thanks for the response.

I am using QOS 2 since the Subscriber is not designed to handle duplicate messages.

Before I open a bug I wanted to clear my understanding and also report one more observation here.

Is the SendWhileDisconnected feature supposed to handle all messages sent even after getting a "connection lost" callback? Or is the application responsible for its own buffering after the callback? Based on the description I believe the Paho library should buffer all messages (up to the specified buffer size) sent even after connection was lost. Can you please clarify?

What I observed is that the MQTTAsync_ API calls are blocking after the "connection lost" callback. The timing of "connection lost" depends on KeepAliveInterval value (shorter value, quicker call-back). The messages sent before the "connection lost" callback are resent after the connection is re-established. But especially the MQTTAsync_isConnected() called by the application (to check connectivity) and the same API called by the internal MQTT_ReceiveThread are blocking on the same mutex. The application is single-threaded.

As a workaround I am buffering my own messages after "connection lost" and wait for connection to reestablish before resending. I am letting the library handle the messages sent after network disconnect, but before the "connection lost" callback (which it does correctly).
Previous Topic:Paho MQTT with Arm Keil MDK
Next Topic:Broken Pipe after idle period
Goto Forum:
  


Current Time: Fri May 03 11:54:37 GMT 2024

Powered by FUDForum. Page generated in 0.02832 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top