Cryptic MQTT client error

maldus
Posts: 83
Joined: Wed Jun 06, 2018 1:41 pm

Cryptic MQTT client error

Postby maldus » Mon Jun 13, 2022 7:29 am

Hello everyone,
I have a project using an ESP32S2 module that connects to a remote MQTT broker with SSL encryption/authentication. I'm on ESP-IDF branch release/v4.4. It all works well most of the time except with a specific query-response procedure where the the broker publishes a command and the device must respond.

Sometimes the device fails to respond and I see the following log in the monitor:

Code: Select all

E (297861) MQTT_CLIENT: mqtt_message_receive: transport_read() error: errno=119
I (297863) MQTT cloud: MQTT_EVENT_ERROR
I (297863) MQTT cloud: Last error code reported from esp-tls: 0x8008
I (297871) MQTT cloud: Last tls stack error number: 0x0
I (297877) MQTT cloud: Last captured errno : 0 (Success)
E (297883) MQTT_CLIENT: mqtt_process_receive: mqtt_message_receive() returned -1
I (297897) MQTT cloud: MQTT_EVENT_DISCONNECTED
The code that prints this error mostly comes from the MQTT example:

Code: Select all

        case MQTT_EVENT_ERROR:
            ESP_LOGI(TAG, "MQTT_EVENT_ERROR");
            if (event->error_handle->error_type == MQTT_ERROR_TYPE_TCP_TRANSPORT) {
                ESP_LOGI(TAG, "Last error code reported from esp-tls: 0x%x", event->error_handle->esp_tls_last_esp_err);
                ESP_LOGI(TAG, "Last tls stack error number: 0x%x", event->error_handle->esp_tls_stack_err);
                ESP_LOGI(TAG, "Last captured errno : %d (%s)", event->error_handle->esp_transport_sock_errno,
                         strerror(event->error_handle->esp_transport_sock_errno));
            } else if (event->error_handle->error_type == MQTT_ERROR_TYPE_CONNECTION_REFUSED) {
                ESP_LOGI(TAG, "Connection refused error: 0x%x", event->error_handle->connect_return_code);
            } else {
                ESP_LOGW(TAG, "Unknown error type: 0x%x", event->error_handle->error_type);
            }
            break;
I'm not sure on how to interpret the reported errors. I don't know where I should look for errno 119, and while code 0x8008 is described as ESP_ERR_ESP_TLS_TCP_CLOSED_FIN in the documentation the remaining logs indicate no failure.
Can anyone help me on how to further diagnose this situation?

ESP_YJM
Posts: 300
Joined: Fri Feb 26, 2021 10:30 am

Re: Cryptic MQTT client error

Postby ESP_YJM » Mon Jun 13, 2022 7:44 am

I think this topic has the same issue with yours. https://www.esp32.com/viewtopic.php?p=98798#p98798. You can refer to.

maldus
Posts: 83
Joined: Wed Jun 06, 2018 1:41 pm

Re: Cryptic MQTT client error

Postby maldus » Mon Jun 13, 2022 8:53 am

I will investigate on why the broker would decide to close the connection. Does this mean I can ignore the other error reports (for example, the errno 119)?

ESP_YJM
Posts: 300
Joined: Fri Feb 26, 2021 10:30 am

Re: Cryptic MQTT client error

Postby ESP_YJM » Tue Jun 14, 2022 2:05 am

Yes, errno 119 you can ignore it. Sometimes, it is not a error.

Who is online

Users browsing this forum: Baidu [Spider] and 82 guests