Not authorized / MQTT5 connect return code is 135 / Connection refused error: 0x87

Hi.

I’m stuck with this error (see log below) trying to connect to hivemq.cloud broker using MQTT5.

I used HiveMQ server certificate that I loaded with esp_tls_set_global_ca_store function (being careful to set the use_global_ca_store MQTT client config struct member to true). I didn’t use SSL mutual authentication (so I didn’t use a private key).

Username and password were double checked. I even created another user to be sure that I didn’t make any mistake when copy-pasting. But anyway if it was caused by a wrong password, the error code would have been different (134/0x86).

Does anyone have an idea of what may cause this error ?

Thank you !

Note that I replaced the URI prefix by XXXXXXXXXXXXX in the pasted log output.

D (11932) mqtt_client: Core selection disabled
D (11936) event: running post MQTT_EVENTS:7 with handler 0x42003208 and context 0x3fca5ea0 on loop 0x3fca659c
D (11953) MQTT5_EXAMPLE: Event dispatched from event loop base=MQTT_EVENTS, event_id=7
D (11961) MQTT5_EXAMPLE: free heap size is 266416, maxminu 266416
I (11967) MQTT5_EXAMPLE: MQTT_EVENT_BEFORE_CONNECT
D (11972) esp-tls: host:XXXXXXXXXXXXX.s2.eu.hivemq.cloud: strlen 51
D (11987) esp-tls: [sock=54] Resolved IPv4 address: 20.79.70.109
D (11988) esp-tls: [sock=54] Connecting to server. HOST: XXXXXXXXXXXXX.s2.eu.hivemq.cloud, Port: 8883
D (12156) esp-tls: handshake in progress...
D (13431) mqtt_client: Transport connected to mqtts://XXXXXXXXXXXXX.s2.eu.hivemq.cloud:8883
D (13432) mqtt_client: Sending MQTT CONNECT message, type: 1, id: 0000
D (13589) mqtt_client: mqtt_message_receive: first byte: 0x20
D (13589) TRANSPORT_BASE: remain data in cache, need to read again
D (13590) mqtt_client: mqtt_message_receive: read "remaining length" byte: 0x43
D (13598) mqtt_client: mqtt_message_receive: total message length: 69 (already read: 2)
D (13606) TRANSPORT_BASE: remain data in cache, need to read again
D (13612) mqtt_client: mqtt_message_receive: read_len=67
D (13617) mqtt_client: mqtt_message_receive: transport_read():69 69
D (13624) mqtt5_msg: MQTT5_PROPERTY_REASON_STRING Please check the URL and if your MQTT client supports TLS SNI
W (13634) mqtt5_client: Not authorized
D (13638) event: running post MQTT_EVENTS:0 with handler 0x42003208 and context 0x3fca5ea0 on loop 0x3fca659c
D (13648) MQTT5_EXAMPLE: Event dispatched from event loop base=MQTT_EVENTS, event_id=0
D (13656) MQTT5_EXAMPLE: free heap size is 230748, maxminu 221188
I (13662) MQTT5_EXAMPLE: MQTT_EVENT_ERROR
I (13667) MQTT5_EXAMPLE: MQTT5 connect return code is 135
I (13673) MQTT5_EXAMPLE: Connection refused error: 0x87
E (13679) mqtt_client: MQTT connect failed

Can anybody help ? I’m still stuck on this.

Thank you.

May be related to Support SNI for http_client without common name check (IDFGH-7865) · Issue #9392 · espressif/esp-idf · GitHub?

Otherwise, ask at https://github.com/espressif/esp-idf/issues