This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRF modem 1.1.1 firmware, 1.2 SDK. Re-using sockets causes hang in nrf_connect.

I'm porting a working app from SDK 1.1 to 1.2, and have noted that when I make an mqtt connection close it, and re-open (to a different mqtt server) that the call to nrf_connect hangs indefinitely.

The socket number is the same, which makes me think that when the first connection closes, it leaves something in a bad state.

The two separate mqtt connections work fine in isolation from each other, just not when the connections are made sequentially. (open, close, open)

Also, I've noted that when I modify the code to make both connections one after the other, forcing the use of another "new" socket for the second connection, things work fine.

This worked fine with modem firmware 1.1.1 and SDK 1.1, so it seems like it might be a new SDK 1.2 bug.

Parents Reply Children
  • Hi.

    We have identified a problem in the modem as the source of this bug.

    As the problem is caused by enabling TLS session caching, the workaround until the modem problem is fixed is to not use TLS session caching.

    The reason for this problem to surface in NCS v1.2.0 is that the newest version of bsdlib enables TLS session caching by default.

    You can therefore either use the previous version of bsdlib (0.6.0), or you can disable TLS session caching using socket options:

    #include <nrf_socket.h>
    
    nrf_sec_session_cache_t session_cache = 0;
    
    nrf_setsockopt(socket, NRF_SOL_SECURE,
    
            NRF_SO_SEC_SESSION_CACHE, &session_cache,
    
            sizeof(session_cache));

    We are working on solving the problem in the modem.

    Best regards,

    Didrik

Related