Hi, I need some pointers to help me out debug a connection issue.
I got a simple setup with and ESP32 and a SimCom A7670 GSM.
I am prototyping using ESP-IDF 5.1.2 and the example tcp_modem_client from the ESP-MODEM component.
What I got tested/validated:
- MQTTconnection to HiveMQ, mosquitto AND eclipeIO test server (non TLS).
- MQTTSconnection (anonymous) to mosquitto and eclipeIO test server.
- MQTTSconnection with MQTT user/pass on flespi ( I had to validate the USER/PASS over TLS).
- connections to my HiveMQ instance using 3rd party MQTTclients (mqttx and mqttspy).
Since I am using a GSM modem I did not try a local install on my own network.
What is not working:
- Connection to my HiveMQ broker using the esp32.
When I trace the VERBOSE output, I can verify that the TLS auth works:
V (6196) sock_dce: 0x3ffba988 39 48 9a b0 13 1b 82 50 75 54 7b be db ea c2 0d |9H.....PuT{.....|
D (6206) sock_dce: perform_at
V (6206) sock_dce: 0x3ffba958 0a 0d 0a 4f 4b 0d 0a |...OK..|
D (6206) mqtt_client: Transport connected to mqtts://xxx.s2.eu.hivemq.cloud:8883
D (6216) sock_dce: perform_at
D (6226) mqtt_client: Sending MQTT CONNECT message, type: 1, id: 0000
D (6226) sock_commands: response
OK
Then it always fails on the MQTT authentication:
V (6236) dce: 0x3ffbac08 17 03 03 00 48 00 00 00 00 00 00 00 01 43 cf ce |....H........C..|
V (6246) dce: 0x3ffbac18 b2 6a 84 aa 87 09 99 0b d6 ee 28 98 b9 a7 e1 c9 |.j........(.....|
V (6256) dce: 0x3ffbac28 69 7a b0 92 a4 f4 b4 e4 41 4b 0d aa 1b 34 55 c5 |iz......AK...4U.|
V (6266) dce: 0x3ffbac38 f8 b0 90 ac 40 50 a2 e9 c2 a5 d3 2d d2 c4 34 52 |....@P.....-..4R|
V (6276) dce: 0x3ffbac48 35 fc 53 0e 22 62 45 a7 27 17 d0 61 2b |5.S."bE.'..a+|
V (6286) sock_dce: 0x3ffba958 0d 0a 3e |..>|
D (6286) sock_dce: perform_at
D (6296) sock_commands: response
>
V (6306) sock_dce: 0x3ffba958 0d 0a 4f 4b 0d 0a 0d 0a 2b 43 49 50 53 45 4e 44 |..OK....+CIPSEND|
V (6306) sock_dce: 0x3ffba968 3a 20 30 2c 37 37 2c 37 37 0d 0a |: 0,77,77..|
D (6316) sock_dce: perform_at
D (6316) sock_commands: response
OK
+CIPSEND: 0,77,77
V (6646) sock_dce: 0x3ffba958 0d 0a 2b 43 49 50 52 58 47 45 54 3a 20 31 2c 30 |..+CIPRXGET: 1,0|
V (6646) sock_dce: 0x3ffba968 0d 0a |..|
D (6656) sock_dce: perform_at
D (6656) sock_commands: response
+CIPRXGET: 1,0
D (6656) sock_commands: Got data on modem!
D (6656) dce: select read: modem data available
V (6666) sock_dce: 0x3ffba958 0d 0a 2b 49 50 43 4c 4f 53 45 3a 20 30 2c 31 0d |..+IPCLOSE: 0,1.|
D (6666) dce: select read: modem data available
V (6676) sock_dce: 0x3ffba968 0a |.|
D (6686) sock_dce: perform_at
E (6696) mqtt_client: esp_mqtt_handle_transport_read_error: transport_read() error: errno=0
V (6696) sock_dce: 0x3ffba958 0d 0a 2b 43 49 50 52 58 47 45 54 3a 20 32 2c 30 |..+CIPRXGET: 2,0|
D (6706) event: running post MQTT_EVENTS:0 with handler 0x400d9358 and context 0x3ffbc5c4 on loop 0x3ffbc4c4
0x400d9358: mqtt_event_handler(void*, char const*, long, void*) at /home/dweezil/VSCode/modem_tcp_client/main/modem_client.cpp:56
V (6716) sock_dce: 0x3ffba968 2c 35 2c 35 39 0d 0a 17 03 03 00 1c 0d 0a 0d 0a |,5,59...........|
D (6726) modem_client: Event dispatched from event loop base=MQTT_EVENTS, event_id=0
V (6736) sock_dce: 0x3ffba978 4f 4b 0d 0a |OK..|
I (6736) modem_client: MQTT_EVENT_ERROR
D (6746) sock_dce: perform_at
I (6756) modem_client: Last error code reported from esp-tls: 0x103
D (6756) sock_commands: response
+CIPRXGET: 2,0,5,59
I (6766) modem_client: Last tls stack error number: 0x0
I (6776) modem_client: Last captured errno : -1 ()
E (6776) mqtt_client: esp_mqtt_connect: mqtt_message_receive() returned -1
E (6786) mqtt_client: MQTT connect failed
V (6796) sock_commands: tcp_close
V (6796) command_lib: generic_command
D (6796) command_lib: generic_command command AT+CIPCLOSE=0
Now, my question is: Does the problem looks like its from the MQTT auth. handshake, does the MQTT config in the ESP needs particular config flags I am missing, or is the issue in the ESP-IDF API/code.
IMO I would validate first that my MQTT config is correct, to enforce my gut feeling that the issue is in the ESP-IDF code…
Any comment is welcome, I’ve been stomped for a few days now on this issue.
Cheers.