E (475768) MQTT_CLIENT: mqtt_message_receive: transport_read() e

ghz 8months ago ⋅ 175 views

E (475768) MQTT_CLIENT: mqtt_message_receive: transport_read() error: errno=128

I am facing some issues while connecting ESP32 to HIVEMQTT broker.

I have attached the output it gives below: This image contains the output from the device.

These are the credentials I have used in the device:

esp_mqtt_client_config_t mqtt_cfg = {
       // .host = "mqtt://broker.hivemq.com",
        .uri = "mqtt://b9f******************************.s2.eu.hivemq.cloud:8883",
        .port = 8883,
        .username = "e**************5",
        .password = "e********",
        .client_id = "Ta******",
       // .event_handle = "mqtt_event_handler",
        .disable_auto_reconnect = false,
        .lwt_qos = 0,
        //.transport = MQTT_TRANSPORT_OVER_TCP,       //choosing TCP over TLS/SSL
    };

    esp_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg);
    esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, client);
    esp_mqtt_client_start(client);

    vTaskDelay(1000);

I am expecting it to connect to the broker, subscribe to create topic then publish a value in it and then subscribe again to fetch the value.

Answers

It seems that you are encountering issues while connecting your ESP32 device to the HiveMQTT broker. From the output provided, it appears that the connection is failing due to an authentication error. This could be caused by incorrect credentials or misconfiguration of the MQTT client.

Here are some steps you can take to troubleshoot and resolve the issue:

  1. Double-check the credentials: Ensure that the username and password provided in the mqtt_cfg structure are correct. Make sure there are no typos or mistakes in the credentials.

  2. Check the MQTT broker URI: Verify that the URI specified in the mqtt_cfg structure is correct and matches the address of the HiveMQTT broker. Also, ensure that you are using the correct port number (8883 for MQTT over TLS/SSL).

  3. Ensure TLS/SSL configuration: Since you are connecting to the broker over MQTT/TLS, ensure that your ESP32 device has the necessary certificates installed to establish a secure connection. HiveMQTT requires TLS/SSL for secure communication.

  4. Verify client ID: Make sure the client ID specified in the mqtt_cfg structure is unique and does not conflict with other MQTT clients.

  5. Check for firewall or network issues: Ensure that there are no firewall rules or network restrictions blocking the connection between your ESP32 device and the HiveMQTT broker. Also, verify that your device has a stable internet connection.

  6. Debugging output: Enable debugging output in your ESP32 code to get more detailed information about the connection process. This can help identify the specific cause of the authentication failure.

  7. Test with MQTT client: Use a separate MQTT client (such as MQTT Explorer or MQTT.fx) to verify that you can connect to the HiveMQTT broker using the same credentials and URI. This can help determine if the issue is specific to your ESP32 device or if there are broader connectivity issues.

By following these steps and troubleshooting the potential causes of the authentication failure, you should be able to successfully connect your ESP32 device to the HiveMQTT broker. If you continue to experience issues, consider reaching out to the support team of HiveMQTT for further assistance.