Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

smartDeviceConnectionDisconnectionEvent : "disconnectReason": "DUPLICATE_CLIENTID", (CA-337) #222

Open
PaulAnurag opened this issue May 28, 2024 · 4 comments

Comments

@PaulAnurag
Copy link

Hello Folks,

I am using the https://github.com/espressif/esp-aws-iot/tree/release/202012.04-LTS branch for my project. In this project, whenever there is a slight disconnection in internet for a couple of seconds, my device goes offline and disconnects for AWS.
On checking the smartDeviceConnectionDisconnectionEvent in aws iot core, I can see the below disconnection event :
{
"clientId": "xxxxxxxxxxxxxxxx",
"timestamp": 1716871954622,
"eventType": "disconnected",
"clientInitiatedDisconnect": false,
"sessionIdentifier": "xxxxxxxxxxxxxxxx",
"principalIdentifier": "xxxxxxxxxxxxxxxx",
"disconnectReason": "DUPLICATE_CLIENTID",
"versionNumber": 6
}

I am trying to tune the different Macros such as :

SDK Config Core Mqtt Macro :

  1. CONFIG_MQTT_STATE_ARRAY_MAX_COUNT=10
  2. CONFIG_MQTT_MAX_CONNACK_RECEIVE_RETRY_COUNT=6
  3. CONFIG_MQTT_PINGRESP_TIMEOUT_MS=10000
  4. CONFIG_MQTT_RECV_POLLING_TIMEOUT_MS=15
  5. CONFIG_MQTT_SEND_TIMEOUT_MS=20000

core_mqtt_config_defaults :

  1. PACKET_TX_TIMEOUT_MS = 30000
  2. PACKET_RX_TIMEOUT_MS = 30000

Please suggest me if there is any change required.

@github-actions github-actions bot changed the title smartDeviceConnectionDisconnectionEvent : "disconnectReason": "DUPLICATE_CLIENTID", smartDeviceConnectionDisconnectionEvent : "disconnectReason": "DUPLICATE_CLIENTID", (CA-337) May 28, 2024
@avsheth
Copy link
Collaborator

avsheth commented May 29, 2024

Hi @PaulAnurag
Ideally the IoT cloud would have set disconnectReason to CONNECTION_LOST in the lifecycle event, had it been disconnected due to network fluctuations. Suggest to check the reason behind DUPLICATE_CLIENTID from the cloud.

As for network resiliency of the device, device could actively disconnect in one of the two conditions:

  1. Device is idle and keep alive fails
    MQTT_KEEP_ALIVE_INTERVAL_SECONDS option in the application can determine this. Default for this in the example is 60s. Parameter indicates that it'll check for connectivity every 60seconds and if doesn't hear back from the cloud within CONFIG_MQTT_PINGRESP_TIMEOUT_MS, it disconnects.

  2. Network fluctuations during some ongoing transaction
    One of the options that can be looked into for this is CONFIG_MQTT_RECV_POLLING_TIMEOUT. If the device is bound to receive some packet/data and network is disconnected, it could detect that and exits from the loop. You may try increasing this to 2000.

However, like I said, the disconnect reason in the lifecycle event should still be different.

@PaulAnurag
Copy link
Author

Hello @avsheth
Thanks for the prompt reply. I will test once keeping the MQTT_KEEP_ALIVE_INTERVAL_SECONDS 60s and increasing the CONFIG_MQTT_RECV_POLLING_TIMEOUT to 2000ms.

Is there any documentation for all the mqtt macro parameters ?

@avsheth
Copy link
Collaborator

avsheth commented Jun 5, 2024

You can read Kconfig parameters in the corresponding Kconfig files or in in the menuconfig window.
For application defined macros, you can read about them just above where they are defined. For example, here.

@PaulAnurag
Copy link
Author

AWS MQTT disconnection and re connection events have decreased a lot after changing the below macros
CONFIG_MQTT_PINGRESP_TIMEOUT_MS - 10000
CONFIG_MQTT_RECV_POLLING_TIMEOUT_MS - 5000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants