Arduino Client for MQTT

Hi,
Quick question (hopefully).

I sometimes get .-2 connection errors when I am trying to reconnect to AWS MQTT Core, sometimes they come and others not, it is inconsistent. It has cropped up because I want to demo the functionality and normally between connections there is a long period, now I have reduced it to less than one minute.

It says here in the API that it is network error but it isn't, due to the inconsistency. Often it will try twice or three times, then let me in.
https://pubsubclient.knolleary.net/api

I think it is because I am not disconnecting properly, then AWS is not handshaking because it thinks I am still connected. The documentation specifies

"cleanSession boolean (optional)"

The existing code implementation of the function is:

mqttClient.connect(broker, 8883)

I have tried to add this cleanSession to the end of the line but can't get anything to work. Ive tried, true, free, and various numbers, the IDE says try 'free' but that doesn't work.

Has anyone tried this?

Thanks

The full syntax of the PubSubClient connect() function when using cleanSession is
boolean PubSubClient::connect(const char *id, const char *user, const char *pass, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage, boolean cleanSession) {

So you need to add values for more parameters and note that cleanSession is a boolean

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.