R410 socket drops on MQTT connections


Hi Everyone,

First thank you for taking the time to read.

I am using a Sara R410M connected to an ESP32 module. I am very experienced with ESP32 but am new to cellular in embedded applications.

My application is to develop a Gateway device with uses the ESP32 as the main processor and the Sara R410 as the connectivity method to the Internet. We’ll be communicating data to various cloud services over MQTT sockets(Azure, AWS IoT, Losant, etc). We have already developed this product with WiFi connectivity(ESP32 stand alone) but now wish to make a cellular variant.

I have written an ESP32 compatible library for the Sara-R410 which implements the functionality of WiFiClient and WiFiClient secure. The application instantiates an object of the library and then passes it to the MQTT PubSub client which then handles connectivity and data transmissions to the cloud. Everything is working perfectly except for the fact that the MQTT socket connection keeps dropping out. I establish a connection to the cloud via MQTT then I read the connection status of the Socket via the at+usoctl=0,10 command in a loop. It returns a 4(connection established) for about 23 seconds, then after that it returns a 9(Last_Ack status) so the application has to connect again.

Can anyone give insight as to why the socket keeps disconnecting after 23 seconds on the Sara R410? I am using a Hologram sim with the data set to unlimited. I have tried this with 3 different cloud services and each time the connection drops after 23 seconds or so.

Thank you



I have determined the cause of the dropped connection is the MQTT Keep Alive timeout. So the server(AWS in this case) is closing the socket since no data or Ping Request has been received for the timeout period specified by the client(ESP32+R410) which was set to 30 seconds. I have determined Ping Requests are being sent from the hardware to AWS but a response is not always received. There seems to be a reliability issue over the cellular connection but still trying to work that out.