Keepalive for 3rd party sim is mandatory?

I am using 3rd party sim for electron and private server for posting messages instead of Particle cloud server.

I did add STARTUP(cellular_credentials_set(…) in the code and working fine so far.

My question is, do I still have to setup keep-alive thing for maintaining connection?
I am asking because my device sometimes fails to post messages to server and had to press reset button if the device didn’t send any messages for a longer period of time.

If you want to contact your device from the remote side you need the communication path to remain open all time - this is what Particle.keepAlive() does.
If you don’t need that but only push data from the device out, then you won’t need keep alive.

To advise more about your issue with push-events not geting delivered we’d need more info about your actual code.

Hi, thanks for your comment.
My application only post message to server and does not require input from the server. So it is good to know that I don’t need to handle keepAlive function.
Since I am only using library implemented here TlsTcpClient library on WebIDE published not exactly sure why electron fails to post message to the server.
So I decided to turn Cellular off and on again to regain connection to the server as below.

void resetNetwork()
   unsigned long connectTime = millis();
   int sec = 0;
   Serial.println("Cellular Off");;
   Serial.println("Cellular On");
   Serial.println("Cellular Connect");
   while(Cellular.connecting()) {
      if((millis() - connectTime) > 1000) {
         connectTime = millis();
         Serial.printf("elapsed %d\r\n",sec);
   STARTUP(cellular_credentials_set("TM", "", "", NULL)); /* SET APN */

After running above code, I finally can re-establish connection to the server.
Do you think this solution is ok?

STARTUP is a macro that has no business inside a function.
If you want to re-set the credentials you’d only need the actual function call not wrapped in STARTUP(...).
I also think it shouldn’t be required to turn off the modem but merely issue some “dummy” request. If that doesn’t help Cellular.disconnect()/Cellular.connect() should suffice.

I did try Cellular.disconnect() and Cellular.connect() but the device only showing glowing green and could not re-establish connection between the server. So I decided to turn off the modem entirely and on.
I will remove the STARTUP code if that is not effective and see if it can regain connection.d