Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] Paho Mqtt C Client: Automatic reconnect issue when connection is lost.

Ok 
Thanks a lot.

On 05-Jul-2017 6:37 PM, "Ian Craggs" <icraggs@xxxxxxxxxxxxxxxxxxxxxxx> wrote:

The onSuccess callback is only invoked as a result of a successful connect attempt in response to an MQTTAsync_connect call.  It will only be invoked once.

If you want to be notified when a connection is re-established as a result of an automatic reconnect then you can use the MQTTAsync_connected callback - use MQTTAsync_setConnected() to set.

On 05/07/2017 12:47, vikas sharma wrote:
Hi Ian

Thanks for your help.I am getting connect failed callback prints all the time for offline reconnection.But connect success callback prints are still not coming.

Just let me know if we can expect connect succes callback prints if it is getting connected successfully after conn lost situation with above mentioned settings.

On Tue, Jul 4, 2017 at 4:35 PM, Ian Craggs <icraggs@xxxxxxxxxxxxxxxxxxxx.uk> wrote:

connectTimeout is the max length of time to be allowed for the connect process to complete: TCP socket connect, MQTT connect and receipt of CONNACK.

keepAlive time is defined by MQTT: to detect whether the TCP connection is still alive after the connect has completed. 

The two settings are independent.  You could try taking a client trace to see if that helps explain what is going on.  Set the environment variables:

MQTT_C_CLIENT_TRACE=ON

and

MQTT_C_CLIENT_TRACE_LEVEL=PROTOCOL (if you just want MQTT packets, leave this out for the full trace)

Ian


On 04/07/2017 06:39, vikas sharma wrote:
Hi

I am using Paho Mqtt C Client on my IMX6 device.Providing below some details regarding my code.

MQTTAsync client;
MQTTAsync_connectOptions conn_opts = MQTTAsync_connectOptions_initializer;

Default connection initializer value.
#define MQTTAsync_connectOptions_initializer { {'M', 'Q', 'T', 'C'}, 4, 60, 1, 10, NULL, NULL, NULL, 30, 0,\
NULL, NULL, NULL, NULL, 0, NULL, 0, 0, 1, 60}


    conn_opts.keepAliveInterval = 5;
    conn_opts.cleansession = 1;
    conn_opts.automaticReconnect = 1;
    conn_opts._onSuccess_ = onConnect;
    conn_opts._onFailure_ = onConnectFailure;
    conn_opts.context = client;

void onConnect(void* context, MQTTAsync_successData* response)
{
    printf("Successful connection\n");
    connectionStatus = CONNECTION_OK;
}

void onConnectFailure(void* context, MQTTAsync_failureData* response)
{
    printf("Connect failed, rc %d\n", response ? response->code : 0);
}


1. The issue i am facing with the sdk is that i am not able to see the prints of onConnectFailure callback sometimes.Although it works fine and i can see the logs most of the time.(2 out of 10 times)
2.
Second issue is i am not able to see onConnect callback prints.If onConnectFailure prints are coming sometimes,same shall be the case with onConnect callback.
3.
What is the exact meaning of connectTimeout value in default initializer.What shall be its value if the keepalive timeout is 5 secs.?













_______________________________________________
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

_______________________________________________
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



_______________________________________________
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

_______________________________________________
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

Back to the top