MQTT Connection keeps getting disconnected/closed while publishing or subscribing to topics using LTE Modem

0
  • 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]	
Aqib
已提问 2 年前2723 查看次数
2 回答
1

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.

KR,

Philipp

AWS
专家
已回答 2 年前
0

Not sure if you are still running into this problem but I was just faced with something similar. I spun up a second device and whenever one contacted AWS the other disconnected. I was sure I had made a mistake with credentials or something but actually I had overlooked an AT command from the MQTT Operation Example. When you send AT+QMTCONN=<client_idx>,<clientID>[,<username>[,<password>]] your clientID needs to be unique for each individual device. Changed clientID to be my thingName and everything has been smooth sailing since.

Hope it helps.

hans

hans
已回答 2 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则