Network call hangs when cell connection disconnects while in `sendmsg`

I'm unsure if this is the correct place to post since this is not a Nordic-specific issue.

I am using the P100 which is a nrf52840 connected to an HL7800 through a UART interface.

My application performs many `mqtt_publish` calls when it receives data from a BLE sensor. It's configured to use the TLS transport, which eventually calls `zsock_sendmsg`. Every once in a while the network disconnects while it's calling `sendmsg` and I get the following logs:

[00:14:17.707,183] <err> net_mqtt: Transport write failed, err_code = -5, closing connection
[00:14:17.707,214] <inf> net_mqtt_sock_tls: Closing socket 0
 

Another thread can then immediately reconnect with no problems, but the thread that sends the data hangs on the `zsock_sendmsg` call.

The only thing I have tried is editing the TLS transport code by adding a `MSG_DONTWAIT` flag to the `sendmsg` call, but that didn't change the behaviour. I am considering adding logic elsewhere to detect if the thread has hung and restarting it using `k_thread_abort` but this doesn't seem like an optimal solution.

If there is anything else that I can try or a solution that is a little cleaner than aborting the thread, then I would appreciate any suggestions. Thanks!

Parents Reply Children
No Data
Related