It appears the MQTT client connection is rejected by the server. The TLS connection has been made, but hasn't finished authenticating yet (sd->connecting is still false, but the connected event is emitted). The mqtt connect should not be called until the TLS client authentication process is completed/authorized by the server.
Here's the output without the delay and some notes:
Connecting with TLS...
Loading the CA root certificate...
Loading certificate file: "certs/rootCA.pem"
Loading the Client certificate...
Loading certificate file: "certs/cert.pem"
Loading the Client Key...
Loading certificate file: "certs/key.pem"
Performing the SSL/TLS handshake...
TLS connected ------------------->(logged in my TLS connected event handler)
Client connected ----------------->(logged in MQTT module connected event)
Verifying peer X.509 certificate... --->(logged ~line 530 of network.c)
MQTT client disconnected --------->(logged in MQTT end event)
Maybe add an authorized event that fires after the authentication process? Or delay the connected event in this scenario?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
It appears the MQTT client connection is rejected by the server. The TLS connection has been made, but hasn't finished authenticating yet (sd->connecting is still false, but the connected event is emitted). The mqtt connect should not be called until the TLS client authentication process is completed/authorized by the server.
Here's the output without the delay and some notes:
Maybe add an authorized event that fires after the authentication process? Or delay the connected event in this scenario?