<?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>MQTT Connection Resets - Keepalive</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/104501/mqtt-connection-resets---keepalive</link><description>I&amp;#39;m hoping someone can view the modem traces I have here to help me understand why the mqtt connection is being reset. I&amp;#39;d like to test a keep-alive on the order of hours, but the connection is being reset at PINGREQs. 
 I&amp;#39;m using a nrf9160DK, MFW 1.3</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 19 Oct 2023 09:06:19 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/104501/mqtt-connection-resets---keepalive" /><item><title>RE: MQTT Connection Resets - Keepalive</title><link>https://devzone.nordicsemi.com/thread/451228?ContentTypeID=1</link><pubDate>Thu, 19 Oct 2023 09:06:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9002c804-ec19-4009-b7f2-b898734e0774</guid><dc:creator>JONATHAN LL</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;So from the logs it seems that the issue is likely the keepalive.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;In both cases a RST, ACK sent from server terminating the TCP connection, this is likely due to the&amp;nbsp;MQTT connection timing out. Even though the client request a certain MQTT keepalive it doesn’t mean that the server supports that value.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;An to add from our expert on the matter:&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;My current conclusion (strong guess without seeing server side traces and/or not knowing how the server side architecture) is that the NAT binding times out on the carrier network side (AT&amp;amp;T) and thus the load balancer / Firewall on the Hive could side (FQDN c59829c0af344d2aa83346efbde5e10c.s1.eu.hivemq.cloud) does not recognize the TCP session anymore (or the session timed out) or the PINREQ packet gets forwarded to a wrong MQTT server as the source IP/Port has changed thus managing existing session mappings. In all cases the cloud side server / load balancer / Firewall responds with RST. Business as usual.&lt;/p&gt;
&lt;p&gt;Why I refer to load balancer / firewall? That is an educated guess based on the IP header identification and TTL fields.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;During the 3-way handshake the server side uses identifications from 0 onwards and TTL is 234.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Once the connection moves to TLS the identification field jumps to e.g. 0x9ad7 onwards → high chances this is a different node behind the load balancer as the “IP session” is completely different. TTL is still the same 234..&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;When the server side responds with an RTS the IP identification is copied from the source packet and but TTL is 208 i.e. not the expected 234 → high chances the RTS comes from a different server or load balancer.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There are few obvious ways to tackle the issue:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;better choice of a protocol.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use of Private/enterprise APNs → no issues with NATs or they are under the control of the customer.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use more aggressive keepalive, which is closer what the NAT timeouts are on the network side.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use of IPv6 instead of IPv4, since there is not NAT issues with IPv6.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;Jonathan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT Connection Resets - Keepalive</title><link>https://devzone.nordicsemi.com/thread/451129?ContentTypeID=1</link><pubDate>Wed, 18 Oct 2023 18:48:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da1026e5-5826-4abb-801c-809432657d27</guid><dc:creator>ERob</dc:creator><description>&lt;p&gt;Thanks Jonathan. Network is AT&amp;amp;T, and using public cloud for the HiveMQ brokers. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT Connection Resets - Keepalive</title><link>https://devzone.nordicsemi.com/thread/450992?ContentTypeID=1</link><pubDate>Wed, 18 Oct 2023 08:50:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:57904d6c-63b6-4184-99a9-a96f927196d9</guid><dc:creator>JONATHAN LL</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Will look at the trace and provide some feedback, update will follow.&lt;br /&gt;&lt;br /&gt;What network provider are you using?&lt;br /&gt;&lt;br /&gt;And are you using public cloud for these brokers or do you host your own servers in HiveMQ?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;Jonathan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>