MQTT Connection keeps getting disconnected/closed while publishing or subscribing to topics using LTE Modem
- I'm using Quectel modem BG95 with a host MCU to connect to AWS IoT core and publish to topics and subscribe to topics as well.
- I used to get an error occasionally that closed the MQTT connection exactly while doing pub/sub operations and connection had to be re-established , but that was very rare.
- However, since the last few days I have been running tests on multiple devices (using same IoT core endpoint) and have been getting this MQTT dis-connection on each pub or sub operation. I am attaching a log for review.
- To me it seems a server side issue since I have tried it with multiple modems and previous versions of firmware.
[While publishing to topic] ;2022-05-08T02:29:41Z;28;-966233403;462863960;;RAK000121|-45,RAKTEST|-56 AT+QIDEACT=1 OK[ 2022-05-08T02:29:41Z ] [FARM_IP][INFO] MDM_SET_DEACTIVATE_PDP-else AT+QIACT=1 OK AT+QMTOPEN=0,"a5u9klmd2viw3z-ats.iot.us-west-1.amazonaws.com",8883 OK +QMTOPEN: 0,0 --- [Opening MQTT Connection] [ 2022-05-08T02:29:41Z ] [FARM_IP][INFO] Mqtt opened AT+QMTCONN=0,"0123qwer786" OK +QMTCONN: 0,0,0 --- [MQTT client connected] AT+QMTPUB=0,1,1,0,"fm/1011",72 --- [Publishing to the MQTT Topic] > ;2022-05-08T02:29:41Z;28;-966233403;462863960;;RAK000121|-45,RAKTEST|-56 OK +QMTSTAT: 0,1 --- [MQTT Connection Closed]
[While Subscribing to topic] AT+QMTSUB=0,1,"imei/get_logs",0 --- [Subscribing to the MQTT Topic] OK +QMTSTAT: 0,1 --- [MQTT Connection Closed] [ ] [FARM_IP][INFO] Starting timer AT+QMTSUB=0,1,"imei/get_logs",0 --- [Subscribing to the MQTT Topic] OK +QMTSTAT: 0,1 --- [MQTT Connection Closed]
What is the payload size you are publishing? Have you enabled CloudWatch logging on the AWS IoT side? What do they tell? What is the disconnection reason you get on the disconnect Lifecycle events? (https://docs.aws.amazon.com/iot/latest/developerguide/life-cycle-events.html)
When you client is disconnected while publishing or subscribing the reason might be the IoT policy that is used. If you are not allowed to publish or subscribe to a topic your client is being disconnected.
You can use CloudWatch logs to drill down this error further. If the IoT policy is the reason you will find an authorization error in CloudWatch logs.
Problem with Ingestion data from IoT Core (MQTT) to AWS SiteWiseasked 5 months ago
com.aws.greengrass.mqttclient.AwsIotMqttClient: Unable to connect to AWS IoT CoreAccepted Answerasked 5 months ago
Using MQTT Bridge and MySensors - getting startedasked a year ago
How can I restrict certain topics when not using AWS Cognito?asked 2 years ago
Publishing messages to IoT core using an imported lambda in greengrassv2asked 2 months ago
MQTT Connection keeps getting disconnected/closed while publishing or subscribing to topics using LTE Modemasked 21 days ago
IoT Core Can Connect, Can Subscribe, Can Not Publishasked 3 years ago
Set up IOT with MQTT?asked 3 months ago
Devices can't connect to IoT CoreAccepted Answerasked 5 months ago
unable to Sub scribing with Mqtt data in AWS IoT core with greengrass deploymentasked a month ago