Calling nrf_send on TLS socket with large payload closing socket with errno -52 ENETRESET

We are currently running on mfw_nrf9160_1.0.1 and NRF master as of today (Sept 13, commit 224bee9).

We are developing an MQTT application that uses TLS mode sockets.

We have bumped into the issue that trying to publish a message that is too large (~2500 bytes) will cause the call to send() down in the MQTT library to fail, returning -1 and setting errno to 52 and closing the socket.

If I rebuild the application using non-TLS sockets, it is able to send the large publish payload without issue.

I have been digging around the NRFX documentation and headers and seen no mention of an upper limit to nrf_send, or how to adjust any buffers.

What is imposing this limit?  Is there a way to know if our call to send is about to hit it before it kills our socket?  How can I work around it?

No Data
  • Here's a super-simple workaround.  This patch is specific to MQTT, but the basic idea should work with any application.  Just  break one big send into lots of smaller ones...

    This really is a bug in nrf_send, though...

    diff --git a/subsys/net/lib/mqtt/mqtt_transport_socket_tls.c b/subsys/net/lib/mqtt/mqtt_transport_socket_tls.c
    index 3ca6265760..97b3eeb366 100644
    --- a/subsys/net/lib/mqtt/mqtt_transport_socket_tls.c
    +++ b/subsys/net/lib/mqtt/mqtt_transport_socket_tls.c
    @@ -120,7 +120,7 @@ int mqtt_client_tls_write(struct mqtt_client *client, const u8_t *data,
            while (offset < datalen) {
                    ret = send(client->transport.tls.sock, data + offset,
    -                          datalen - offset, 0);
    +                          MIN(1024,(datalen - offset)), 0);
                    if (ret < 0) {
                            return -errno;

No Data