MQTT connection problems

Hi,
I have been developing a measurement system where data from RuuviTAGs is sent to Azure via Ruuvi Gateway. Connection has been working well except two times when MQTT messaging has been stopped without any reason. First time I solved the situation by resetting the gateway but now even reset didnā€™t work. I have checked the debug log and there is not much MQTT related at all, I donā€™t know should there be more than messages than just after boot, see below. I can see that HTTP messaging to Ruuvi Cloud is working so the problem is not with Wifi.

I was thinking could it be because the gateway tries to send status message before MQTT connection is valid causing MQTT to stop at all?

I (4920) MQTT: [wifi_manager] mqtt_app_start
I (4925) MQTT: [wifi_manager] Using server: xx.xx.xx.xx, client id: ā€˜RuuviGatewayā€™, topic prefix: ā€˜devices/RuuviGatewayXXXX/messages/events/ā€™, port: 8883, user: ā€˜Azureā€¦/?api-version=2018-06-30ā€™, password: ā€˜******ā€™
I (4951) MQTT: [mqtt_task] MQTT_EVENT_BEFORE_CONNECT
I (4950) LEDS: [wifi_manager] leds_indication_on_network_ok
I (4964) LEDS: [wifi_manager] LED: OFF
I (4968) ADV_POST_TASK: [adv_post_task] Handle event: NETWORK_CONNECTED
I (4969) TIME: [time_task] Activate SNTP time synchronization
I (4981) http: [adv_post_task] HTTP POST to URL=https://network.ruuvi.com/status, DATA:
{
ā€œDEVICE_ADDRā€: ā€œAB:AB:BB:35:2ā€:FF",
ā€œESP_FWā€: ā€œv1.9.2ā€,
ā€œNRF_FWā€: ā€œv0.7.2ā€,
ā€œUPTIMEā€: ā€œ1ā€,
ā€œNONCEā€: ā€œ1082287059ā€,
ā€œCONNECTIONā€: ā€œWIFIā€,
ā€œNUM_CONN_LOSTā€: ā€œ0ā€,
ā€œSENSORS_SEENā€: ā€œ9ā€,
ā€œACTIVE_SENSORSā€: [{
ā€œMACā€: ā€œDA:FE:0E:8A:52:22ā€,
ā€œCOUNTERā€: ā€œ2ā€
}, {
ā€œMACā€: ā€œDA:FE:0E:8A:52:23ā€,
ā€œCOUNTERā€: ā€œ2ā€
}, {
ā€œMACā€: ā€œDA:FE:0E:8A:52:24ā€,
ā€œCOUNTERā€: ā€œ2ā€
}],
ā€œINACTIVE_SENSORSā€: [ā€œFA:AC:A5:89:79:2Aā€]
}
W (5753) ADV_POST_TASK: [rx_parse_task] Canā€™t send, MQTT is not connected yet
W (5755) ADV_POST_TASK: [rx_parse_task] Canā€™t send, MQTT is not connected yet
W (5761) ADV_POST_TASK: [rx_parse_task] Canā€™t send, MQTT is not connected yet
W (5768) ADV_POST_TASK: [rx_parse_task] Canā€™t send, MQTT is not connected yet
W (5786) ADV_POST_TASK: [rx_parse_task] Canā€™t send, MQTT is not connected yet
W (5853) ADV_POST_TASK: [rx_parse_task] Canā€™t send, MQTT is not connected yet
I (5983) MQTT: [mqtt_task] MQTT_EVENT_CONNECTED
I (5984) MQTT: [mqtt_task] esp_mqtt_client_publish: topic:ā€˜devices/RuuviGateway/messages/events/gw_statusā€™, message:ā€˜{ā€œstateā€: ā€œonlineā€}ā€™
I (5995) MQTT: [mqtt_task] esp_mqtt_client_publish: message_id=6804
I (5998) LEDS: [mqtt_task] leds_indication_on_network_ok
I (6004) LEDS: [mqtt_task] LED: OFF
ā€¦
I (560784) http: [adv_post_task] HTTP POST to URL=https://network.ruuvi.com/record, DATA:
I (562152) http: [adv_post_task] HTTP POST to URL=https://network.ruuvi.com/record: STATUS=200
I (562156) LEDS: [adv_post_task] leds_indication_on_network_ok
I (562157) LEDS: [adv_post_task] LED: OFF

Hello,

Can you give us some more details?

  • What firmware version youā€™re running?
  • Are you sending to Ruuvi Cloud with http at the same time?
  • Are you sending statistics with the Gateway?

Hi,
Iā€™m using v1.9.2. I think the problems is actually the lack of logging i.e. MQTT actions are not logged same way as HTTP to Ruuvi Cloud. So the is no way to see if the gateway is sending MQTT or not.
Iā€™m sending data to both Ruuvi Cloud and Azure and send statistics is on.

Hi

Do you have a virtual server at Azure site? If yes, you should see the network connection from your gateway in the netstat table of your VM. I have used the MQTT server in Azure VM for some months and, I have to say, there has been zero communication problems due to gateway so far. Other problems due to my own stupidities in my own network setup I have well met.

Hi,
I donā€™t have virtual server, Iā€™m using Azure IoT Hub that accepts direct MQTT connections from Ruuvi Gateway.
I think the Ruuvi Gateway is not the problem but because there is no logging for MQTT, Iā€™m not able to see why messages are not received at the Azure end.
Could it be possible to include MQTT logging similarly than HTTP logging is implemented at the moment?

The problem with logging messages with MQTT is that MQTT sends all data as it comes. This leads to meaningless clutter in logs.

You still should see the connected, ā€œstatus:onlineā€ message and disconnected events in the logs. You can also use the test.mosquitto.org default MQTT server to check the data sent by Gateway.

Thanks for clarifying the functionality.

So when there is no MQTT in the log, everything is working ok.