"mqtt disconnect" issues from switch example in esp32

Hello. Happy day

The esp32 device is located in the st-device-sdk-c-ref/apps/esp32/switch_example path
Testing switch_example code.

There were 2 problems during the test.
I would like to ask for your help with the reason and how to solve it.

  1. The first issue
  2. Test Environment
  • phone : samsung galaxy s23
  • android ver : 14
  • smartthings ver : 1.8.17.22
  • app automation conditions

[app image]

  1. Issue
  • case 1
  • Auto iteration condition 7 hours or so in the app “Routine run but some actions don’t run” message and wait for the app in a stopped state.
  • case 2
  1. “mqtt idn’t get PINGRESP” ------> After “MQTT connection success” during automation, app is waiting. (No message in app)

[esp32 log]


Sequence number return : 1



ellipsis (…)…

Sequence number return : 2590

I (77769496) [IoT]: iot_cap_commands_cb(1106) > command : {“commands”:[{“id”:“6c111c3c-b16d-41f6-aa7b-592fbe8061f7”,“component”:“main”,“capability”:“switch”,“command”:“off”,“arguments”:}]}

Notification message received I (77802726) [IoT]: iot_cap_sub_cb(908) > command : {“commands”:[{“id”:“1183915f-ce78-466e-97f4-3024041fe340”,“component”:“main”,“capability”:“switch”,“command”:“on”,“arguments”:}]}

called [caps_switch_cmd_on_cb] func with num_args:0 I (77802736) [IoT]: st_cap_send_attr(613) > publish event, topic : /v1/deviceEvents/3a743cb9-acb9-4420-a421-790356f3b394, payload : {“deviceEvents”:[{“component”:“main”,“capability”:“switch”,“attribute”:“switch”,“value”:“on”,“providerData”:{“sequenceNumber”:2591,“timestamp”:“1724283963339”}}]}

Sequence number return : 2591

I (77802766) [IoT]: iot_cap_commands_cb(1106) > command : {“commands”:[{“id”:“1183915f-ce78-466e-97f4-3024041fe340”,“component”:“main”,“capability”:“switch”,“command”:“on”,“arguments”:}]}

Notification message received

W (77958796) [IoT]: _iot_mqtt_check_alive(877) > mqtt didn’t get PINGRESP

I (77958806) [IoT]: st_mqtt_disconnect(1434) > mqtt disconnect 0

I (77958806) [IoT]: _iot_net_show_status(89) > [1073427092] network socket status: sockfd 1724284119 readable 0 writable 54 sock_err 0 errno 0

I (77958846) [IoT]: iot_es_connect(1086) > connect_type: log-in I (77958846) [IoT]: _iot_es_mqtt_connect(925) > url: mqtt-regional-apnortheast2.api.smartthings.com, port: 8883

I (77958856) [IoT]: _iot_es_mqtt_connect(931) > mqtt connect, id : 4fa08feb-9099-4a06-a102-4e3e4d64c372 username : 3a743cb9-acb9-4420-a421-790356f3b394 password : eyJhbGciOiJFZERTQSIsImt0eSI6Ik9LUCIsImNydiI6IkVkMjU1MTkiLCJ0eXAiOiJKV1QiLCJ2ZXIiOiIwLjAuMSIsImtpZCI6IlNUREtIZlE1MjBpV0k1emMifQ==.eyJpYXQiOiIxNzI0Mjg0MTE5IiwianRpIjoiNWQwYzMyNDQtNTc0Zi00MTFiLWIxM2QtYmE4NjViMmViZjQ2IiwibW5JZCI6ImZ3SzMifQ==.4bfH5kgJIb6ZIN6FSum+mM8rdrdMZ1HsFjOkHt6TU3BBiJvSxFq2wogVxcY3bcEPcWS22qRnzr11hIyVeUvcAg==

I (77958896) [IoT]: _iot_net_tls_connect(416) > Loading the CA root certificate 1317@0x3ffb85a4

I (77959296) [IoT]: iot_es_connect(1106) > MQTT connect success sucess/try : 2/2

I (77959346) [IoT]: _check_connection_response(79) > Connection response payload {“target”:“3a743cb9-acb9-4420-a421-790356f3b394”,“currentTime”:1724284121,“localMigrated”:false,“event”:“connect.success”}


  1. “mqtt idn’t get PINGRESP” ------> “MQTT connection success” occurs several times during automation and app is waiting. (No messages in app)

[esp32 log]

  1. “mqtt idn’t get PINGRESP” ------> “MQTT connection success” occurs and app is waiting while automation is not running. (No messages in app)

[esp32 log]

  1. Analysis of the phenomenon where automation stops working
  • Automation conditions are violated during the process of disconnecting and reconnecting mqtt.
  1. Questions
  1. Why is mqtt connection disconnected?
  2. Is there a way to prevent mqtt connection from being disconnected?
  3. Should I reduce the “time out” time for checking mqtt connection?
  4. Is there a way to restore the previous automation operation after mqtt reconnection?
  5. Why does an error occur in the app like case1?

Thank you.

[app message] “Routine run but some actions don’t run”

[Issue case2-3]