AirGradient Forum

MQTT weirdness -- user/password information deleted from the config

I have an MQTT broker in Home Assistant. It requires userid/password to access. Various entities are successfully using it. Using a

curl -X PUT -H "Content-Type: application/json" -d '{"mqttBrokerUrl":"mqtt://user:pass@192.168.4.15"}' airgradient.${secret}.com/config

command I can see from tcpdump that the user/password is set. Airgradient issues one successful connexion to the MQTT broker, then disconnects, and deletes the user/password from the config.
Subsequent MQTT connexions fail.

I can verify that the config information is lost shortly after I set it.

hubris% curl -X PUT -H "Content-Type: application/json" -d '{"mqttBrokerUrl":"mqtt://user:pass@192.168.4.15"}' airgradient.${secret}.com/config
Success
hubris% curl -X GET airgradient.${secret}.com/config |  jq | grep mqt
  "mqttBrokerUrl": "mqtt://user:pass@192.168.4.15",
hubris% curl -X GET airgradient.${secret}.com/config |  jq | grep mqt
  "mqttBrokerUrl": "mqtt://user:pass@192.168.4.15",
hubris% curl -X GET airgradient.${secret}.com/config |  jq | grep mqt
  "mqttBrokerUrl": "mqtt://user:pass@192.168.4.15",
hubris% curl -X GET airgradient.${secret}.com/config |  jq | grep mqt
  "mqttBrokerUrl": "mqtt://user:pass@192.168.4.15",
hubris% curl -X GET airgradient.${secret}.com/config |  jq | grep mqt
  "mqttBrokerUrl": "mqtt://user:pass@192.168.4.15",
hubris% curl -X GET airgradient.${secret}.com/config |  jq | grep mqt
  "mqttBrokerUrl": "mqtt://user:pass@192.168.4.15",
hubris% curl -X GET airgradient.${secret}.com/config |  jq | grep mqt
  "mqttBrokerUrl": "mqtt://user:pass@192.168.4.15",
hubris% curl -X GET airgradient.${secret}.com/config |  jq | grep mqt
  "mqttBrokerUrl": "mqtt://user:pass@192.168.4.15",
hubris% curl -X GET airgradient.${secret}.com/config |  jq | grep mqt
  "mqttBrokerUrl": "mqtt://192.168.4.15",

Any ideas?
This is my I-9 with the latest firmware.

Hi @mogul, maybe the port number is missing in your URL? (1883)

In case you would like to learn more about setting up an MQTT URL via local API: https://www.airgradient.com/documentation/kb/configure-mqtt-via-local-api

Port number implicit.
Tcpdump was restricted to the mqtt default port.
Shows successful connection via tcp and successful mqtt protocol con and conack when password is supplied.
Next the session is closed.
Subsequent sessions fail due to the user and password having been removed from the configuration and thus not presented.

Difficult to capture info from home assistant ssh terminal thing but I will try to get the details tomorrow.

1 Like

@mogul, thank you for the clarification. Please feel free to let me know when you have further details. In the meantime, I will try to reproduce the issue.

I have a pcap file. Can I DM it to you?
Anyway, for this test, I made the port # explicit, just for grins, and again, the I-9 successfully logged into MQTT broker, closed the conx, and cleared all the info except the IP from the config.

hubris% curl -X PUT -H "Content-Type: application/json" -d '{"mqttBrokerUrl":"mqtt://user:pass@192.168.4.15:1883"}' airgradient.${secret}.com/config
Success                                                                                                                                                                                                                                                         
hubris% curl -X GET airgradient.${secret}.com/config 2>/dev/null |  jq | grep mqt
  "mqttBrokerUrl": "mqtt://user:pass@192.168.4.15:1883",
hubris% curl -X GET airgradient.${secret}.com/config 2>/dev/null |  jq | grep mqt
  "mqttBrokerUrl": "mqtt://user:pass@192.168.4.15:1883",
hubris% curl -X GET airgradient.${secret}.com/config 2>/dev/null |  jq | grep mqt
  "mqttBrokerUrl": "mqtt://192.168.4.15",

You can sort of see whats going on below. The I-9 keeps establishing an MQTT session with the broker, using the bare URL. These are connect-connack sequences, where the connack contains an error code, so no disconnect.
Then I supply the correct URL, it connects, the connack is OK, and then is issues a disconnect.
Immediately thereafter, it goes back to the failing sequences.

   34  45.130205 192.168.4.62 → 192.168.4.15 MQTT 80 Connect Command
   35  45.130280 192.168.4.15 → 192.168.4.62 TCP 54 1883 → 61015 [ACK] Seq=1 Ack=27 Win=64214 Len=0
   36  45.130320 192.168.4.15 → 192.168.4.62 MQTT 58 Connect Ack
   37  45.130326 192.168.4.15 → 192.168.4.62 TCP 54 1883 → 61015 [FIN, ACK] Seq=5 Ack=27 Win=64214 Len=0
   38  45.132984 192.168.4.62 → 192.168.4.15 TCP 54 61015 → 1883 [ACK] Seq=27 Ack=6 Win=5755 Len=0
   39  45.135652 192.168.4.62 → 192.168.4.15 TCP 54 61015 → 1883 [FIN, ACK] Seq=27 Ack=6 Win=5755 Len=0
   40  45.135683 192.168.4.15 → 192.168.4.62 TCP 54 1883 → 61015 [ACK] Seq=6 Ack=28 Win=64214 Len=0
   41  50.148056 192.168.4.62 → 192.168.4.15 TCP 58 61016 → 1883 [SYN] Seq=0 Win=5760 Len=0 MSS=1436
   42  50.148117 192.168.4.15 → 192.168.4.62 TCP 58 1883 → 61016 [SYN, ACK] Seq=0 Ack=1 Win=64240 Len=0 MSS=1460
   43  50.150983 192.168.4.62 → 192.168.4.15 TCP 54 61016 → 1883 [ACK] Seq=1 Ack=1 Win=5760 Len=0
   44  50.152698 192.168.4.62 → 192.168.4.15 MQTT 106 Connect Command
   45  50.152724 192.168.4.15 → 192.168.4.62 TCP 54 1883 → 61016 [ACK] Seq=1 Ack=53 Win=64188 Len=0
   46  50.152833 192.168.4.15 → 192.168.4.62 MQTT 58 Connect Ack
   47  50.172954 192.168.4.62 → 192.168.4.15 TCP 54 61016 → 1883 [ACK] Seq=53 Ack=5 Win=5756 Len=0
   48 101.888909 192.168.4.62 → 192.168.4.15 MQTT 56 Disconnect Req
   49 101.889007 192.168.4.15 → 192.168.4.62 TCP 54 1883 → 61016 [FIN, ACK] Seq=5 Ack=55 Win=64186 Len=0
   50 101.891631 192.168.4.62 → 192.168.4.15 TCP 54 61016 → 1883 [ACK] Seq=55 Ack=6 Win=5755 Len=0
   51 101.925270 192.168.4.62 → 192.168.4.15 TCP 54 61016 → 1883 [FIN, ACK] Seq=55 Ack=6 Win=5755 Len=0
   52 101.925292 192.168.4.15 → 192.168.4.62 TCP 54 1883 → 61016 [ACK] Seq=6 Ack=56 Win=64186 Len=0
   53 101.926325 192.168.4.62 → 192.168.4.15 TCP 58 61019 → 1883 [SYN] Seq=0 Win=5760 Len=0 MSS=1436
   54 101.926385 192.168.4.15 → 192.168.4.62 TCP 58 1883 → 61019 [SYN, ACK] Seq=0 Ack=1 Win=64240 Len=0 MSS=1460
   55 101.928946 192.168.4.62 → 192.168.4.15 TCP 54 61019 → 1883 [ACK] Seq=1 Ack=1 Win=5760 Len=0
   56 101.931717 192.168.4.62 → 192.168.4.15 MQTT 80 Connect Command
   57 101.931737 192.168.4.15 → 192.168.4.62 TCP 54 1883 → 61019 [ACK] Seq=1 Ack=27 Win=64214 Len=0
   58 101.931766 192.168.4.15 → 192.168.4.62 MQTT 58 Connect Ack
   59 101.931797 192.168.4.15 → 192.168.4.62 TCP 54 1883 → 61019 [FIN, ACK] Seq=5 Ack=27 Win=64214 Len=0
1 Like

(post deleted by author)

1 Like

@mogul, thank you for your quick reply! Could you send the file via our support ticket? Please also make sure you clean up all the unnecessarily sensitive data before sending it to us. I can pass it on to our engineer to investigate this issue. Thanks a lot!

(post deleted by author)

1 Like