<?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>How to detect that the peer closed a TCP socket</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/77552/how-to-detect-that-the-peer-closed-a-tcp-socket</link><description>Hello, 
 I am using the NCS v1.5.0, the nRF9160 SoC and the modem has firmware version mfw_nrf9160_1.2.3 
 Based on the UDP sample, I created an application that has opens a TCP listening server then waits for a client to connect. I am using blocking</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 04 Oct 2021 13:42:31 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/77552/how-to-detect-that-the-peer-closed-a-tcp-socket" /><item><title>RE: How to detect that the peer closed a TCP socket</title><link>https://devzone.nordicsemi.com/thread/332381?ContentTypeID=1</link><pubDate>Mon, 04 Oct 2021 13:42:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d78f0fae-0800-4620-bdb8-c9ed27d0f8ad</guid><dc:creator>NelsonGoncalves</dc:creator><description>&lt;p&gt;Hello Markus,&lt;/p&gt;
&lt;p&gt;Updating the modem firmware to version 1.3.0 fixed the issue.&lt;/p&gt;
&lt;p&gt;And looking at the Wireshark traces, the modem is also properly closing the TCP session&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/tcl_5F00_close_5F00_mfw_5F00_1.3.0.pcapng"&gt;devzone.nordicsemi.com/.../tcl_5F00_close_5F00_mfw_5F00_1.3.0.pcapng&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to detect that the peer closed a TCP socket</title><link>https://devzone.nordicsemi.com/thread/331782?ContentTypeID=1</link><pubDate>Wed, 29 Sep 2021 17:12:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03b055d1-b5e5-4414-9c46-673b1ff180df</guid><dc:creator>Albrecht Markus Schellenberger</dc:creator><description>&lt;p lang="en-GB"&gt;Hello again,&lt;/p&gt;
&lt;p lang="en-GB"&gt;could you update your modem firmware to version 1.3.0 and check if that makes any difference? I got the feedback from our development team that during their tests with mfw 1.3.0, poll sets event NRF_POLLHUB successfully .&lt;/p&gt;
&lt;p lang="en-GB"&gt;Regards,&lt;/p&gt;
&lt;p lang="en-GB"&gt;Markus&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to detect that the peer closed a TCP socket</title><link>https://devzone.nordicsemi.com/thread/331638?ContentTypeID=1</link><pubDate>Wed, 29 Sep 2021 08:31:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d33ac19-5e09-44bf-a94f-7b33ae5e1e63</guid><dc:creator>Albrecht Markus Schellenberger</dc:creator><description>&lt;p&gt;Hello Nelson,&lt;/p&gt;
&lt;p&gt;Just a quick update: currently, we do not have the test setup to reproduce the issue you are facing, but our development team is looking into it as we speak. I will hopefully be able to provide you with some more updates soon.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Markus&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to detect that the peer closed a TCP socket</title><link>https://devzone.nordicsemi.com/thread/330032?ContentTypeID=1</link><pubDate>Fri, 17 Sep 2021 12:13:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc830036-cf66-4a59-b005-b4f8cae5fc70</guid><dc:creator>Albrecht Markus Schellenberger</dc:creator><description>&lt;p lang="en-GB"&gt;Hello Nelson,&lt;/p&gt;
[quote user="NelsonGoncalves"]In the attached Wireshark file, my PC (the client) has IP address 192.168.178.29 and the nRF9160 module (the server) has IP address 178.50.73.204. The Wireshark tracing&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/8358.test_5F00_nordic.pcapng"&gt;test_nordic.pcapng&lt;/a&gt;[/quote]
&lt;p lang="en-GB"&gt;Thanks a lot for your input!&lt;/p&gt;
[quote user="NelsonGoncalves"]Any updates ?[/quote]
&lt;p lang="en-GB"&gt;Still no news from the development team. My very apologies for that! I will try to push on this one and come back to you.&lt;/p&gt;
&lt;p lang="en-GB"&gt;&lt;/p&gt;
&lt;p lang="en-GB"&gt;Regards,&lt;/p&gt;
&lt;p lang="en-GB"&gt;Markus&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to detect that the peer closed a TCP socket</title><link>https://devzone.nordicsemi.com/thread/329983?ContentTypeID=1</link><pubDate>Fri, 17 Sep 2021 10:27:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6974ecda-4293-4f5f-8206-f35110289f51</guid><dc:creator>NelsonGoncalves</dc:creator><description>&lt;p&gt;Hello Markus,&lt;/p&gt;
&lt;p&gt;Any updates ? In the meanwhile, I took a look with Wireshark at the network traffic.&lt;/p&gt;
&lt;p&gt;On the nRF9160DK I have my TCP listening application running, and I connect to it with from my PC and send ten times a test string. To each one the module replies by upper casing the text. Then my PC application closes the socket. Again, on the module side there is no notification that the client has closed the socket.&lt;/p&gt;
&lt;p&gt;From the Wireshark tracing, the TCP packet sequence for when the PC closes the socket is:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;PC sends TCP packet with FIN and ACK&lt;/li&gt;
&lt;li&gt;Module replies with ACK&lt;/li&gt;
&lt;li&gt;PC tries to send, but apparently fails, a TCP packet with RST and ACK&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In the attached Wireshark file, my PC (the client) has IP address 192.168.178.29 and the nRF9160 module (the server) has IP address 178.50.73.204. The Wireshark tracing&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/test_5F00_nordic.pcapng"&gt;devzone.nordicsemi.com/.../test_5F00_nordic.pcapng&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;With the debugger, I can see that the application on the nrf9160 module is stuck in the idle task and I don&amp;#39;t understand why. could this be related to the issues I am having ?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to detect that the peer closed a TCP socket</title><link>https://devzone.nordicsemi.com/thread/327123?ContentTypeID=1</link><pubDate>Mon, 30 Aug 2021 07:54:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a62c1760-3bff-41cf-8089-4983c079f886</guid><dc:creator>Albrecht Markus Schellenberger</dc:creator><description>&lt;p lang="en-GB"&gt;Hello Nelson,&lt;/p&gt;
&lt;p lang="en-GB"&gt;I haven’t received any updates from our development team yet. But I’ll check with them again.&lt;/p&gt;
&lt;p lang="en-GB"&gt;Regards,&lt;/p&gt;
&lt;p lang="en-GB"&gt;Markus&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to detect that the peer closed a TCP socket</title><link>https://devzone.nordicsemi.com/thread/326532?ContentTypeID=1</link><pubDate>Wed, 25 Aug 2021 11:56:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad416953-a240-4aae-9e3a-917c38cb1269</guid><dc:creator>NelsonGoncalves</dc:creator><description>&lt;p&gt;Hello Markus,&lt;/p&gt;
&lt;p&gt;Any updates ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I did not try to update the firmware of the modem because I am using a prototype board, and I don&amp;#39;t to risk bricking the only prototype we have.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Nelson&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to detect that the peer closed a TCP socket</title><link>https://devzone.nordicsemi.com/thread/323544?ContentTypeID=1</link><pubDate>Thu, 05 Aug 2021 12:55:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dfeb300b-6206-4cbc-b3df-9a1470c1ba4a</guid><dc:creator>Albrecht Markus Schellenberger</dc:creator><description>&lt;p lang="en-GB"&gt;Thank you, Nelson!&lt;/p&gt;
&lt;p lang="en-GB"&gt;I will be on vacation for the next couple of weeks as well.&lt;/p&gt;
&lt;p lang="en-GB"&gt;Regards,&lt;/p&gt;
&lt;p lang="en-GB"&gt;Markus&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to detect that the peer closed a TCP socket</title><link>https://devzone.nordicsemi.com/thread/322698?ContentTypeID=1</link><pubDate>Fri, 30 Jul 2021 14:27:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:28c5ad1a-0650-4c8c-9b06-e73d7de8e8f5</guid><dc:creator>NelsonGoncalves</dc:creator><description>&lt;p&gt;Hello Markus,&lt;/p&gt;
&lt;p&gt;I could not find the time to update the modem firmware, but I will try it out when I return from hollidays.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Nelson&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to detect that the peer closed a TCP socket</title><link>https://devzone.nordicsemi.com/thread/322631?ContentTypeID=1</link><pubDate>Fri, 30 Jul 2021 10:11:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d03c85e4-eea4-473f-bcc4-3144f0944fcd</guid><dc:creator>Albrecht Markus Schellenberger</dc:creator><description>&lt;p lang="en-GB"&gt;Hello Nelson,&lt;/p&gt;
[quote user="NelsonGoncalves"]Side note: I will be on vacation the next two and half weeks.[/quote]
&lt;p&gt;&amp;nbsp;thanks a lot for the heads-up.&lt;/p&gt;
[quote user="NelsonGoncalves"]Should I also try to update the modem firmware version ?[/quote]
&lt;p&gt;I’m quite sure that this is not a modem issue, but to exclude this one from the list of possible root causes, I would appreciate if you could update and check with the newest mfw as well.&lt;/p&gt;
[quote user="NelsonGoncalves"]I tried with NCS v1.6.0 and using poll() for reading from the client socket. Again, when the remote client closes its end, nothing happens on the server side.[/quote]
&lt;p lang="en-GB"&gt;I’ll inform our development team and let you know as soon as I get any news.&lt;/p&gt;
&lt;p lang="en-GB"&gt;I appreciate your patience!&lt;/p&gt;
&lt;p lang="en-GB"&gt;Regards,&lt;/p&gt;
&lt;p lang="en-GB"&gt;Markus&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to detect that the peer closed a TCP socket</title><link>https://devzone.nordicsemi.com/thread/322608?ContentTypeID=1</link><pubDate>Fri, 30 Jul 2021 08:36:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b775404b-272e-40bd-9b46-cfe51a30ba84</guid><dc:creator>NelsonGoncalves</dc:creator><description>&lt;p&gt;Hello Markus,&lt;/p&gt;
&lt;p&gt;I tried with NCS v1.6.0 and using poll() for reading from the client socket. Again, when the remote client closes its end, nothing happens on the server side. Should I also try to update the modem firmware version ?&lt;/p&gt;
&lt;p&gt;Side note: I will be on vacation the next two and half weeks.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Nelson&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to detect that the peer closed a TCP socket</title><link>https://devzone.nordicsemi.com/thread/322570?ContentTypeID=1</link><pubDate>Fri, 30 Jul 2021 05:35:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d964e29-d4f3-4d0a-9e37-23e6a23ecf46</guid><dc:creator>Albrecht Markus Schellenberger</dc:creator><description>&lt;p lang="en-GB"&gt;Hello again Nelson,&lt;/p&gt;
&lt;p lang="en-GB"&gt;I wonder if you could build your application from NCS v1.6.0 and check if you can reproduce this error?&lt;/p&gt;
&lt;p lang="en-GB"&gt;Regards,&lt;/p&gt;
&lt;p lang="en-GB"&gt;Markus&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to detect that the peer closed a TCP socket</title><link>https://devzone.nordicsemi.com/thread/322173?ContentTypeID=1</link><pubDate>Wed, 28 Jul 2021 09:02:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ebc2f045-4a6c-4f73-9033-ab40845e3325</guid><dc:creator>Albrecht Markus Schellenberger</dc:creator><description>&lt;p lang="en-GB"&gt;Hello Nelson,&lt;/p&gt;
&lt;p lang="en-GB"&gt;I unfortunately haven’t been able to receive any information from our modem team yet as many of them still are on vacation. I will try to ping them one more time and come back to you as soon as possible.&lt;/p&gt;
&lt;p lang="en-GB"&gt;My apologies for the inconvenience caused!&lt;/p&gt;
&lt;p lang="en-GB"&gt;Regards,&lt;/p&gt;
&lt;p lang="en-GB"&gt;Markus&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to detect that the peer closed a TCP socket</title><link>https://devzone.nordicsemi.com/thread/322078?ContentTypeID=1</link><pubDate>Tue, 27 Jul 2021 14:25:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a18851bb-f740-4964-8100-ca95c0dc300a</guid><dc:creator>NelsonGoncalves</dc:creator><description>&lt;p&gt;Hello Markus,&lt;/p&gt;
&lt;p&gt;Any updates on this issue ? I tried other alternatives (e.g. reading from the socket and closing it case or error),&amp;nbsp;but this also does not work. After I close the socket, recv() returns -1 but errno is always zero.&lt;/p&gt;
&lt;p&gt;[update 28/07/2021] The SO_KEEPALIVE socket option is apparently not available, and using getsockopt() to get the state/error of the client socket also does not detect that the socket was closed.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;And sending a custom ping to test the connection is not possible, the protocol does not support it.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Nelson Gon&amp;ccedil;alves&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to detect that the peer closed a TCP socket</title><link>https://devzone.nordicsemi.com/thread/320399?ContentTypeID=1</link><pubDate>Fri, 16 Jul 2021 10:24:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:712dcd84-1766-48bc-8c87-f23d28f4ba40</guid><dc:creator>Albrecht Markus Schellenberger</dc:creator><description>&lt;p lang="en-GB"&gt;Hello Nelson,&lt;/p&gt;
&lt;p lang="en-GB"&gt;Yes, this should work exactly as you expect. Once peer closes the connection, &lt;code&gt;poll()&lt;/code&gt;&amp;nbsp;should return &lt;code&gt;POLLHUP&lt;/code&gt;&amp;nbsp;event and the consecutive &lt;code&gt;recv()&lt;/code&gt;&amp;nbsp;call should return 0.&lt;/p&gt;
&lt;p lang="en-GB"&gt;I have to check this with out modem team. Due to summer vacation period most of our experts are out of office currently, but I will come back to you as soon as possible.&lt;/p&gt;
&lt;p lang="en-GB"&gt;Regards,&lt;/p&gt;
&lt;p lang="en-GB"&gt;Markus&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>