Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] Embedded-C C++ client: reconnecting after broker crash?

Hi Joe,

no, you're not missing something. I need to fix this. Are you getting the code from the Paho git repository?

Ian

On 04/07/2015 04:19 PM, Joe Planisky wrote:
I'm using the C++ embedded client and am running into a situation I don't quite understand.

My client connects to a broker and subscribes to some topics with QoS 1.  Everything works fine.  Later the broker crashes, all client and subscription info is lost.  I restart the broker and my client application code reconnects and tries to resubscribe, but the calls to Client.subscribe() fail.

Looking at Client::subscribe() in the source code, I see that it always tries to assign a message handler to an empty slot in the messageHandlers array.  If there are no more empty slots, the subscribe fails.  The problem is that it seems there's no way to remove handlers from the messageHandlers array beyond creating a new Client instance.

To put it another way, here's what I expected to be able to do:

- create a Client
- connect to broker (clean_session = true)
- subscribe to topics
- receive pubs
- broker crashes | network failure, Client senses problem and isconnected = false.
- broker restarts
- same client instance connects to broker (clean_session = true)
- subscribe to (same) topics
- continue receiving pubs

(I don't care about missing any pending pubs lost in the broker crash, hence the clean_session = true on the reconnect.)

Am I missing something, or is creating a new Client instance the only way to reconnect to a broker?

--
Joe

_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/paho-dev

--
Ian Craggs
icraggs@xxxxxxxxxx                 IBM United Kingdom
Paho Project Lead; Committer on Mosquitto



Back to the top