MQTT client on the QBG96 module timing out

Hello.

I am running a simple MQTT client on the QBG96 module (I have been following the instructions in the “Quectel_BG96_MQTT_Application_Note_V1.0.pdf”).

I am connecting to mosquitto.org (which is a simple public MQTT test broker that I’ve used for development numerous times without any issues).
The connection to mosquitto is unencrypted so I am using port 1883 - there is NO username, password, or special certificates required to connect to it either.

I am entering the series of commands through tera-term (cuitting and pasting from a text document)

I seem to be having a major timing issue - After I submit the “AT+QMTCONN” command, within a few seconds, the connection appears to be terminated - here is the output of the entire setup:


RDY
AT+CFUN=1
OK
AT+QCSQ
+QCSQ: “CAT-M1”,-42,-71,166,-13

OK
AT+CEREG?
+CEREG: 0,1

OK
AT+COPS?
+COPS: 0,0,“Verizon Wireless”,8

OK
AT+QIACT=1
OK
AT+QIACT?
+QIACT: 1,1,1,“100.75.83.231”

OK
AT+QMTCFG=“aliauth”,0
+QMTCFG: “aliauth”,"","",""

OK
AT+QMTOPEN=0,“test.mosquitto .org”,1883
OK

+QMTOPEN: 0,0
AT+QMTCONN=0,“mosquitto”
OK

+QMTCONN: 0,0,0

+QMTCONN: 0,1

+QMTSTAT: 0,3


(NOTE: After the +QMTCONN: 0,1 response arrives, any AT+QMT command I attempt to send results in ERROR)

So, I started over and IMMEDIATELY after sending the AT+QMTCONN=0,“mosquitto” (within 1 second), I then subscribe to a topic successfully and managed to receive one message from the broker:

AT+QMTCFG=“aliauth”,0
+QMTCFG: “aliauth”,"","",""

OK
AT+QMTOPEN=0,“test.mosquitto .org”,1883
OK

+QMTOPEN: 0,0
AT+QMTCONN=0,“mosquitto”
OK

+QMTCONN: 0,0,0
AT+QMTSUB=0,1,“my_topic”,0
OK

+QMTSUB: 0,1,0,0

+QMTRECV: 0,0,“my_topic”,“Hey Now”

+QMTCONN: 0,1

+QMTSTAT: 0,3


(NOTE: The received message was just “Hey Now”)

But, again after a few seconds, the connection dies (hence the +QMTCONN: 0,1 status)

My questions:

Q1. Is it my responsibility to keep the connection alive or is this handled inside the modem itself?

Q2. If it IS my responsibility to keep the connection alive, How do I do it?

Q3. Is there a timeout value to set to keep this connection alive?
NOTE: In my testing, I tried various “keepalive” times and none of them made a difference.
AT+QMTCFG=“keepalive”,0,60
AT+QMTCFG=“keepalive”,0,500
AT+QMTCFG=“keepalive”,0,1000
AT+QMTCFG=“keepalive”,0,3600

For reference, here is the sequence of commands I am sending:

// Turn on cellular functionality
AT+CFUN=1

// Check the received signal strength
AT+QCSQ

// Query network registration status (0,1=Registered, on home network, 0,5=Registered, roaming) other - not connected
AT+CEREG?

// Query network technology and carrier:
AT+COPS?

// Activate PDP context
AT+QIACT=1

// Confirm PDP context was activated
AT+QIACT?

// Configure MQTT session
AT+QMTCFG=“aliauth”,0

// Open the mosquitto client
AT+QMTOPEN=0,“test.mosquitto .org”,1883

// Connect to the client.
AT+QMTCONN=0,“mosquitto”

// Subscribe to a topic
AT+QMTSUB=0,1,“my_topic”,0

Thanks in advance for your help!

Dave…

Hi Daener123,

1 .Bg96 module will send heart beat packet to server automaticlly. it will handle inside.
2. we donot support external heart beat packet .
3. Pls check the following setting in your module , the default value is 120s.


For disconnection issue ,Many factors will affect it (e,g loss network,oos ), we need to collect modem log for more analysis .

Hi guys,

We are experiencing the same problem…please, could you share the fix?

Thanks in advance!

hello guys
I have the same problem. Have you solved this problem?

now
I am getting messages by refreshing my subscription every 10 seconds. However, there is a problem of disconnecting the subscription after several times.

We have the same problem, we are using a 3rd party mqtt broker service and we get disconnected.
the raw details:

  • happens mainly on CAT-M1 network.
  • we do get disconnection message from the modem using AT command BUT only after 30 minutes from disconnections!
  • we have a cellular provider that can give us pcap files, in those files we can see many TCP re transmissions and eventually FIN, meaning the latancy of CAT-M1 might be the issue

We have devised a method that is costly in packets data but works, kind of keep alive of our own.

  1. create a channel for keepalive
  2. subscribe to the channel.
  3. every X ticks\seconds send an mqtt to that channel.
  4. set a timer
  5. if the timer expires and no mqtt message was received with the data you have sent - connection is dead.
  6. dead connections needs to be reseted and restarted (connect, resubscribe)
  7. make sure to send all data using QOS1 so the server will relay the data for you untill you reconnect to prevent data loss.

if Qucktel have an idea why their mqtt client is taking so long to notify about a disconnection and how to setup the mqtt properly on CAT-M1 network it will be great.