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.