<?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>Keep socket open indefinitely</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/108483/keep-socket-open-indefinitely</link><description>Hello, Modem firmware is 1.3.5 and SDK version is 2.5.0. I am using Nrf9160 DK to evaluate a cellular network to control, for example, LED remotely. 
 At the moment I am trying to achieve this using a simple socket. Nrf91 connects to the server through</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 26 Apr 2024 13:17:17 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/108483/keep-socket-open-indefinitely" /><item><title>RE: Keep socket open indefinitely</title><link>https://devzone.nordicsemi.com/thread/480902?ContentTypeID=1</link><pubDate>Fri, 26 Apr 2024 13:17:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb2e0b50-7ee2-4108-b180-aa4a2a589d4f</guid><dc:creator>Charlie</dc:creator><description>&lt;p&gt;Hi Eizens,&lt;/p&gt;
[quote user="Eizens"]But using these long keep-alive periods I am running the risk - if the connection is lost, I won&amp;#39;t know this for 1 hour. In the electronic lock case, this could be a bad user experience.&amp;nbsp;[/quote]
&lt;p&gt;This is really a design choice for your lock application. There are some factors like below may have influence on the choice.&lt;/p&gt;
&lt;p&gt;How frequent the cellular connection will have problem?&lt;/p&gt;
&lt;p&gt;How long time you expect to find the device lost connection, and how long time you can fix the issue, then how long time you think customer will not feel bad from issue appear to fix?&lt;/p&gt;
&lt;p&gt;For the cellular connection issue, this could be aware from both nRF9160 and network operator side, you may check with your operator if there is API for this kind of notification.&lt;/p&gt;
&lt;p&gt;I also want to remind you we have a&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.6.0/nrf/samples/matter/lock/README.html"&gt;Matter: Door lock — nRF Connect SDK 2.6.0 documentation (nordicsemi.com)&lt;/a&gt;&amp;nbsp;sample available here.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Charlie&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Keep socket open indefinitely</title><link>https://devzone.nordicsemi.com/thread/477406?ContentTypeID=1</link><pubDate>Sat, 06 Apr 2024 20:35:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:50c21941-2716-45d4-9aeb-ddc097eea65d</guid><dc:creator>Eizens</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;Thank you for the answer. I checked the links and implemented the MQTT.&lt;br /&gt;&lt;br /&gt;A little bit about my application: I am developing a sort of electronic lock. This means the user should be able to open the lock anytime.&amp;nbsp;Meaning my device must always have an open connection with the backend server.&lt;br /&gt;&lt;br /&gt;MQTT uses a keep-alive mechanism to keep the underlying TCP socket open. I have read that&amp;nbsp;in some applications the default MQTT keep-alive period is 60 seconds, but for battery-powered devices, the 60-second keep-alive consumes too much power.&amp;nbsp;The measured current is around 2.5mA (my setup uses RCC idle, no eDRX or PSM).&amp;nbsp;&lt;br /&gt;&lt;br /&gt;So to decrease the device&amp;#39;s power consumption, I tried longer MQTT keep-alive values. With my local cellular network provider SIM I could get a reliable connection&amp;nbsp;using a 1 hour MQTT keep-alive period. In this case, the measured current was around 400uA, which is acceptable. If I increased the keep-alive period any more, I would lose connection. (By the way iBASIS&amp;nbsp;SIM card using data roaming connected to the same local network had only max 5 minute reliable keep-alive period)&lt;br /&gt;&lt;br /&gt;But using these long keep-alive periods I am running the risk - if the connection is lost, I won&amp;#39;t know this for 1 hour. In the electronic lock case, this could be a bad user experience.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So as I understand I don&amp;#39;t have a better option? This means the best option is to find a balance between reliable keep-alive value and power consumption. Could you say this is a normal practice? Maybe you have experience with long MQTT keep-alive periods usage in real-world applications?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Keep socket open indefinitely</title><link>https://devzone.nordicsemi.com/thread/470122?ContentTypeID=1</link><pubDate>Wed, 21 Feb 2024 21:31:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03a65021-dcf1-4218-b0c6-93e402e383ec</guid><dc:creator>helsing</dc:creator><description>&lt;p&gt;Also check out the lesson on &lt;a href="https://academy.nordicsemi.com/courses/cellular-iot-fundamentals/lessons/lesson-1-cellular-fundamentals/topic/lesson-1-power-saving-techniques/"&gt;Power saving techniques&lt;/a&gt; in the course.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Keep socket open indefinitely</title><link>https://devzone.nordicsemi.com/thread/470121?ContentTypeID=1</link><pubDate>Wed, 21 Feb 2024 21:28:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d32044ac-377f-49bc-a8bc-7f59b7697716</guid><dc:creator>helsing</dc:creator><description>&lt;p&gt;Hello Eizens,&lt;/p&gt;
&lt;p&gt;This is covered in&amp;nbsp;DevAcademy &lt;a href="https://academy.nordicsemi.com/courses/cellular-iot-fundamentals/lessons/lesson-4-cellular-fundamentals/"&gt;Lesson 4 – Reading buttons and controlling LEDs over MQTT&lt;/a&gt;. Please let us know if you run into any issues.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>