nrf9160 mqtt keep alive longer than 30 minutes not working

sdk: 1.6

modem fw: 1.2.3

Hi,

Been trying to test mqtt every which way and not getting any success with mqtt keep alive longer than 30 minutes, the mqtt connection is only maintained when the keepalive is less than 30 minutes. Two problems are:

1. setting KEEPALIVE values 1800 or larger than that, the connection just gets dropped.

2. Cant figure out how to set 'will message'. What I currently have in the code I get, "mqtt_connect... -12". which is #define ENOMEM 12 /* Not enough space */.

Removing the will message solves the connection issue, but keepalive issue persists.

Regards

Noaman

  • Hello, 

    A keepalive of more than 30 minutes can be problematic depending on network policies i.e. IP address lease time, etc.

    Can you please provide full log output, including information provided by "AT+CFUN?"

    Thanks.

    Kind regards,
    Øyvind

  • Hi Oyvind,

    I had given up on this until I had to come back to it just recently.

    Please find attached the Uart output with debug enabled. I just cannot get the keep-alive period longer than 30 minutes to work. I have even test disabled PSM, using edrx, using PSM of 5 minutes etc. to try and keep the connectiion with LTE network active. I also checked with Bell and Rogers support they both informed me that they do not put any such limitation on keeping the connection open. Bell also confirm that their IP lease time should be more than 4 hours and longer so the 30 minutes time out does not work.

    I was just thinking about how gps also does a cold-start if fixes are requested more than 30 mintues apart. Is there anything in the modem fw that resets the connection, closes the socket or clears the memory?

    I am using mfw: 1.2.3 

    sdk 1.6

    Regards

    Noaman

  • Hello Noaman, 

    Please note that due to Easter Holiday, our tech support team is lower staffed than normal, and a delay in answers must be expected.




    First of all, from the logs you have provided I see the following

    PSM Settings: +CPSMS: 1,,,"00100100","00000001"
    
    CEREG: +CEREG: 5,1,"D6E4","086B9411",7,,,"11100000","11100000"

    Your network does not provide PSM, i.e. GPS would not work if not setting modem function to e.g. Flight Mode. 

    Stratosphere said:
    I just cannot get the keep-alive period longer than 30 minutes to work.

    Could you please explain what keepalive you are referring to, MQTT or the network? 


    The MQTT server you are connecting to, does this use TLS? Have you verified that the MQTT server does not disconnect device?

    We will need a modem trace for more information.

    Kind regards;
    Øyvind

  • Your network does not provide PSM, i.e. GPS would not work if not setting modem function to e.g. Flight Mode. 

    ...

    I tried many configurations both with and without PSM. This output i shared is where i disable PSM.

    Could you please explain what keepalive you are referring to, MQTT or the network? 

    As per the title of the ticket, I am referring to MQTT keepalive of more than 30 minutes.

    The MQTT server you are connecting to, does this use TLS? Have you verified that the MQTT server does not disconnect device?

    I have tried both with and without TLS, the result is no different. 
    I know my mqtt server does not disconnect because I have tried keepalive to the same server on ESP32 as well and desktop Mqtt client and they both keep the connection.

    Modem trace as well as other files are attached.

  • Stratosphere said:
    I know my mqtt server does not disconnect because I have tried keepalive to the same server on ESP32 as well and desktop Mqtt client and they both keep the connection.

    Is the ESP32 connecting via cellular or WiFi? 

    mqtt keep alive longer than 30 minutes

    Can you provide some information for why you want to have 30 minutes keepalive? This for our developers to understand what you are trying to achieve. 

    oys said:
    Please note that due to Easter Holiday, our tech support team is lower staffed than normal, and a delay in answers must be expected.
Related