<?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>First HTTPS socket connect() success, subsequent connect always hangs</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/59108/first-https-socket-connect-success-subsequent-connect-always-hangs</link><description>Hello, 
 I&amp;#39;m having issues connecting over TLS more than a single time. Using the nrf/samples/nrf9160/https_client works fine. 
 
 However, if you modify it to connect more than once , it fails (assuming you do close the socket fd ). I made a modifications</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 17 Mar 2020 15:30:04 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/59108/first-https-socket-connect-success-subsequent-connect-always-hangs" /><item><title>RE: First HTTPS socket connect() success, subsequent connect always hangs</title><link>https://devzone.nordicsemi.com/thread/240299?ContentTypeID=1</link><pubDate>Tue, 17 Mar 2020 15:30:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:861d4e4e-e34b-4367-90fe-93a84dd0ac07</guid><dc:creator>psychogenic</dc:creator><description>&lt;p&gt;Yes, that does the trick.&amp;nbsp; Thank you much.&lt;/p&gt;
&lt;p&gt;Can you point me to the place where know issues are listed?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: First HTTPS socket connect() success, subsequent connect always hangs</title><link>https://devzone.nordicsemi.com/thread/240026?ContentTypeID=1</link><pubDate>Mon, 16 Mar 2020 13:30:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3228c2d-2d04-4803-87e7-ecb199ca1947</guid><dc:creator>anicare-tero</dc:creator><description>[quote userid="81181" url="~/f/nordic-q-a/59108/first-https-socket-connect-success-subsequent-connect-always-hangs/239996"]Are you certain that you close your sockets properly? It sounds a bit like you are running out of sockets.[/quote]
&lt;p&gt;Yep, that was the problem. I had earlier modified the code to open and close socket differently, but I changed the code back to how it is in https_client sample and not it works. Thanks a lot, Didrik!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: First HTTPS socket connect() success, subsequent connect always hangs</title><link>https://devzone.nordicsemi.com/thread/239996?ContentTypeID=1</link><pubDate>Mon, 16 Mar 2020 12:36:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3ec735e-b03d-48ef-9b51-b755197b8622</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/ziirou"&gt;anicare-tero&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It does not sound like you have the same problem as the original post. That problem would occur every time on the second connection, with connect not returning instead of giving an error.&lt;/p&gt;
&lt;p&gt;Are you certain that you close your sockets properly? It sounds a bit like you are running out of sockets.&lt;/p&gt;
&lt;p&gt;If that does not help you either, I recommend you open a new ticket where you provide a modem trace.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Didrik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: First HTTPS socket connect() success, subsequent connect always hangs</title><link>https://devzone.nordicsemi.com/thread/239988?ContentTypeID=1</link><pubDate>Mon, 16 Mar 2020 12:13:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4af0799b-9386-4da8-a297-3611cf2056b2</guid><dc:creator>anicare-tero</dc:creator><description>&lt;p&gt;Hi Didrik,&lt;/p&gt;
[quote userid="81181" url="~/f/nordic-q-a/59108/first-https-socket-connect-success-subsequent-connect-always-hangs/239974"]As a workaround, you can either disable TLS session caching using socket options:[/quote]
&lt;p&gt;That didn&amp;#39;t help me. I&amp;#39;m still getting same errors. Could the problem be that I&amp;#39;m using&amp;nbsp;setsockopt() for peer verification (that is also used in https_client sample) and your suggestion&amp;nbsp;uses&amp;nbsp;nrf_setsockopt()?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: First HTTPS socket connect() success, subsequent connect always hangs</title><link>https://devzone.nordicsemi.com/thread/239974?ContentTypeID=1</link><pubDate>Mon, 16 Mar 2020 11:47:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a5ca5403-40b2-4400-a39a-6444a45444c5</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;Bsdlib v0.6.1 enabled TLS session caching by default. However, this triggers a bug in the modem when trying to re-connect to a server.&lt;/p&gt;
&lt;p&gt;As a workaround, you can either disable TLS session caching using socket options:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;nrf_sec_session_cache_t session_cache = 0;

nrf_setsockopt(socket, NRF_SOL_SECURE,

        NRF_SO_SEC_SESSION_CACHE, &amp;amp;session_cache,

        sizeof(session_cache));&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Or, you can go back to the previous version of bsdlib (v0.6.0) by changing the revision checked out by west in the ncs/nrf/west.yml file on line 72 to 3e381d09f1d305e230435f5b6e4c9ef928b6a697, and running west update.&lt;/p&gt;
&lt;p&gt;We are working on fixing the bug.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Didrik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: First HTTPS socket connect() success, subsequent connect always hangs</title><link>https://devzone.nordicsemi.com/thread/239896?ContentTypeID=1</link><pubDate>Mon, 16 Mar 2020 08:41:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bcc95737-b220-45f7-9f42-bb6a6188db8a</guid><dc:creator>anicare-tero</dc:creator><description>&lt;p&gt;I&amp;#39;m having this same problem, except I have this error message: &amp;quot;Error: connect() failed, errno: 12&amp;quot;&lt;/p&gt;
&lt;p&gt;Usually, I&amp;#39;m getting 3-4 successful connections but then I will always have those connect errors.&lt;/p&gt;
&lt;p&gt;I would really need help with this too.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>