<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Calling nrf_send on TLS socket with large payload closing socket with errno -52 ENETRESET</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/52129/calling-nrf_send-on-tls-socket-with-large-payload-closing-socket-with-errno--52-enetreset</link><description>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</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 16 Sep 2019 07:30:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/52129/calling-nrf_send-on-tls-socket-with-large-payload-closing-socket-with-errno--52-enetreset" /><item><title>RE: Calling nrf_send on TLS socket with large payload closing socket with errno -52 ENETRESET</title><link>https://devzone.nordicsemi.com/thread/209759?ContentTypeID=1</link><pubDate>Mon, 16 Sep 2019 07:30:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1521e6bc-4afd-405f-92b9-fd615c7d8246</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;[quote][/quote]&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;What is imposing this limit?&amp;nbsp; Is there a way to know if our call to send is about to hit it before it kills our socket?&amp;nbsp; How can I work around it?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This is lacking from our documentation.&lt;/p&gt;
&lt;p&gt;The bsd_limits.h file shows 4k on a AT level:&amp;nbsp;&lt;a href="https://github.com/NordicPlayground/nrfxlib/blob/master/bsdlib/include/bsd_limits.h#L47"&gt;https://github.com/NordicPlayground/nrfxlib/blob/master/bsdlib/include/bsd_limits.h#L47&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;However, does not state anything about IP and TLS.&amp;nbsp;I&amp;#39;ll report this internally.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Just to confirm your suspicions; as per v1.0.x, the limit for TLS data is 2k.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Calling nrf_send on TLS socket with large payload closing socket with errno -52 ENETRESET</title><link>https://devzone.nordicsemi.com/thread/209688?ContentTypeID=1</link><pubDate>Fri, 13 Sep 2019 18:27:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:921c5121-bbfc-4338-8ee1-5c4466b9c06a</guid><dc:creator>jbrzozoski</dc:creator><description>&lt;p&gt;Here&amp;#39;s a super-simple workaround.&amp;nbsp; This patch is specific to MQTT, but the basic idea should work with any application.&amp;nbsp; Just&amp;nbsp; break one big send into lots of smaller ones...&lt;/p&gt;
&lt;p&gt;This really is a bug in nrf_send, though...&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="diff"&gt;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 &amp;lt; datalen) {
                ret = send(client-&amp;gt;transport.tls.sock, data + offset,
-                          datalen - offset, 0);
+                          MIN(1024,(datalen - offset)), 0);
                if (ret &amp;lt; 0) {
                        return -errno;
                }&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>