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

nRF9160 MQTT with TLS disconnects if subscribing

Environment:
nrf9160DK v0.8.2
nRF Connect SDK v1.2.0
Modem firmware: v1.2.0
Toolchain: gcc-arm-none-eabi-9-2019-q4-major-win32

I started with the nrf mqtt_simple sample and modified it to enable TLS support.
Connection to the broker succeeds, and when doing only publish there are no problems, but if there are any subscriptions the second publish results in an error and disconnect.
The error occurs in client_write in mqtt.c  when calling mqtt_transport_write, errno is set to 128.
(mqtt_transport_write calls mqtt_client_tls_write which again calls nrf91_socket_offload_send).

The problem has been reproduced with two different brokers. The only message at the broker side is that the client has disconnected.
Using the same keys with mosquitto_pub/mosquitto_sub works fine.

Jon

Related