BC66 Carrier Reconnection

I have some doubts about how to handle carrier disconnections.

I am using BC66 OpenCPU for connecting the device over a TCP connection. It is a persistent connection that automatically handles TCP reconnection in case of connection timeout with the server.

It seems to work great, even restarting the remote server for upgrades, but after some days (normally less than a week), the device stops working, and the logs on the device indicate that the software is just trying to connect to the TCP server, without success.

Some information. At the startup, I am disabling some power mode capabilities, as the device is expected to be permanently connected and answering server requests in a timely manner:

I am disabling sleep mode:

Disabling power saving mode:

Disabling eDRX

Enabling Full Functionality

Then, I just wait for CREG and start the TCP connection right away. Not sure if the modem is expected to automatically handle all the required reconnections to the carrier, i.e., in case of signal loss, or should I force a reconnection in some way? i.e. calling AT+CFUN=0 and then AT+CFUN=1 again?

What is expected workaround here? Do you have any other experience with devices permanently connected on TCP, i.e., over MQTT?

hi, alvarolb
Now your device is rebooted and can’t connect to TCP normally?

If I completely reboot the device, it works fine for the following days.

Actually you mean you can’t implement TCP long connections?

Yes. If I keep the device connected for a few days, at some point it stops working. I saw the device connected for more than two or three days, handling TCP reconnections, etc. But at some point, it cannot start a connection again. On the 1NCE platform, i can see PDP Context deleted.

Restarting the device does the job.

How often do you send or receive data?

Every minute at least, there is a keep alive on the TCP protocol.

This event is usually related to the radio network or SIM card, do you have no method in your program to deal with this event?

This is what I was asking. At this moment, I don’t know what is the best approach to “restart” the carrier connection. I can detect that the connection timed out, to handle a TCP reconnection, but I am not sure what is the proper way to detect this event and, reconnect to the network?

If this event is related to a radio network or SIM card, I suggest that your program should do the following
step1:Close the TCP connection and re-establish the TCP connection. If the TCP connection fails, go to step2
step2:Run at+cfun=0 and at+cfun=1 to reconnect the network