<?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_CONNECT fails with error -95</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/57270/mqtt_connect-fails-with-error--95</link><description>Hi, 
 Just trying to run mqtt sample with TLS and AWS IoT backend. Everything worked fine in the beginning, but then after I tweaked the code a bit I suddenly started getting error -95 during the connect. 
 Error -95 is not documented in NRF, but I found</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 05 Feb 2020 15:45:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/57270/mqtt_connect-fails-with-error--95" /><item><title>RE: MQTT_CONNECT fails with error -95</title><link>https://devzone.nordicsemi.com/thread/232892?ContentTypeID=1</link><pubDate>Wed, 05 Feb 2020 15:45:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:62bc180a-ccb1-42bd-9eab-54cfae55c1d6</guid><dc:creator>_dev_</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;&amp;Oslash;yvind,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Sorry for taking your time.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Such a shame, but I moved to following line from global context into &lt;em&gt;client_init&lt;/em&gt; method and, of course, memory (stack) gets released as it is a local variable!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;sec_tag_t sec_tag_list[] = {SEC_TAG};&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;So once memory is released something else takes it, this is why some random code such as printk affected on the connection.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It is all good now and ticket can be closed.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;Thanks&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT_CONNECT fails with error -95</title><link>https://devzone.nordicsemi.com/thread/232731?ContentTypeID=1</link><pubDate>Wed, 05 Feb 2020 07:49:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ad5809b-aafb-45f1-89a3-54c9258ca182</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Can you please provide which MQTT sample you based your project on?&lt;br /&gt;&amp;nbsp;&lt;/p&gt;
[quote user="_dev_"]In fact, AWS_FOTA works with my own certificates, but if I use exactly the same certificates in my project I get&amp;nbsp;&amp;#39;ERROR: mqtt_connect -45&amp;#39;[/quote]
&lt;p&gt;&amp;nbsp;Ok, so there is an issue with your certificates. Do you connect to the same server in your project as in AWS_FOTA? &amp;nbsp;In AWS_FOTA have a look at &lt;a href="https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/e0cc5879d1bde02e3333dedcf8720d745c31b3d0/samples/nrf9160/aws_fota/src/main.c#L381"&gt;client_init()&lt;/a&gt;.&amp;nbsp;What is the&amp;nbsp;&lt;span&gt;CONFIG_CLOUD_CERT_SEC_TAG configured in your project vs AWS_FOTA. This is where the certificates are stored in the modem, and your project needs to point to the same.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Kind regards,&lt;br /&gt;Øyvind&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT_CONNECT fails with error -95</title><link>https://devzone.nordicsemi.com/thread/232646?ContentTypeID=1</link><pubDate>Tue, 04 Feb 2020 15:53:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b36c7539-dbff-4789-88fd-e81fc8b0abf3</guid><dc:creator>_dev_</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;&amp;Oslash;yvind,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks for the suggestion.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In fact, AWS_FOTA works with my own certificates, but if I use exactly the same certificates in my project I get&amp;nbsp;&amp;#39;ERROR: mqtt_connect -45&amp;#39;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have also tried to write certificates using AWS_FOTA project and then use them in my project with no luck.&amp;nbsp;&lt;/span&gt;&lt;span&gt;I&amp;#39;m currently comparing my project code with the example and so far see no difference, only cosmetic changes.&amp;nbsp;&lt;/span&gt;&lt;span&gt;I have a feeling that there is something dumb in my code.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Is there a way to enable some verbose logging around using certificates?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT_CONNECT fails with error -95</title><link>https://devzone.nordicsemi.com/thread/232295?ContentTypeID=1</link><pubDate>Mon, 03 Feb 2020 12:00:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b983202-c15e-4a9f-91d1-26f9adae925c</guid><dc:creator>&amp;#216;yvind</dc:creator><description>[quote user="_dev_"]&lt;span&gt;&lt;span&gt;Sorry, I should&amp;#39;ve been more clear.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;The error happens here&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;[/quote]
&lt;p&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;rc = mqtt_connect(c);
if (rc != 0) {
    ...&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This code is only found in the Zephyr samples, did you have look at the &lt;a href="https://github.com/NordicPlayground/fw-nrfconnect-nrf/tree/v1.1.0/samples/nrf9160/mqtt_simple"&gt;mqtt_simple sample&lt;/a&gt;&amp;nbsp;or &lt;a href="https://github.com/NordicPlayground/fw-nrfconnect-nrf/tree/v1.1.0/samples/nrf9160/aws_fota"&gt;AWS_FOTA sample&lt;/a&gt;. As these samples are officially written by Nordic Semiconductor and have been tested with nRF9160. I have had little or no issues with MQTT and TLS using these.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Kind regards,&lt;br /&gt;Øyvind&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT_CONNECT fails with error -95</title><link>https://devzone.nordicsemi.com/thread/232282?ContentTypeID=1</link><pubDate>Mon, 03 Feb 2020 10:45:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e14094bf-dfcd-4623-afc3-d0e09e6c22cc</guid><dc:creator>_dev_</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;&amp;Oslash;yvind,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks for the quick response.&lt;/span&gt;&lt;/p&gt;
[quote userid="77062" url="~/f/nordic-q-a/57270/mqtt_connect-fails-with-error--95/232269"]Can you provide more information on what version of NCS you are using? Master or v1.1.0?[/quote]
&lt;p&gt;v1.1.0&lt;/p&gt;
[quote userid="77062" url="~/f/nordic-q-a/57270/mqtt_connect-fails-with-error--95/232269"]What tweak did you add? Have you tried reverting back to the original?[/quote]
&lt;p&gt;&lt;span&gt;&lt;span&gt;Basically I have just added TLS support to MQTT.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
[quote userid="77062" url="~/f/nordic-q-a/57270/mqtt_connect-fails-with-error--95/232269"]Is this where you are receiving ERRNO -95? What happens if you add the printk in the main loop after calling client_init()?[/quote]
&lt;p&gt;&lt;span&gt;&lt;span&gt;Sorry, I should&amp;#39;ve been more clear.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;The error happens here&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;rc = mqtt_connect(c);
if (rc != 0) {
    ...&lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;But it is caused by &amp;#39;printk&amp;#39; from a completely different method. I know this sounds stupid, but basically unrelated code somehow&amp;nbsp;influences&amp;nbsp;on the mqtt_connect function. It is a single threaded application though.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;I was thinking that maybe it is something to do with memory management.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;I&amp;#39;m currently checking few other&amp;nbsp;things. Will let you know if found something.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;Thanks.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;Upd.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;Deeper debugging showed that the actual error is 45, which gets converted to 95 in&amp;nbsp;bsd_os_errno_set in bsd_os.c:214.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT_CONNECT fails with error -95</title><link>https://devzone.nordicsemi.com/thread/232269?ContentTypeID=1</link><pubDate>Mon, 03 Feb 2020 09:44:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:44b557af-7b1d-493d-8538-a6a1ddcc3c2d</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can you provide more information on what version of NCS you are using? Master or v1.1.0?&lt;/p&gt;
[quote user=""]Everything worked fine in the beginning, but then after I tweaked the code a bit I suddenly started getting error -95 during the connect.[/quote]
&lt;p&gt;What tweak did you add? Have you tried reverting back to the original?&lt;/p&gt;
[quote user=""]As an example below, a simple &lt;em&gt;printk&lt;/em&gt; on line 325 basically breaks the mqtt connection. By commenting that line everything works again. This is 100% consistent.[/quote]
&lt;p&gt;&amp;nbsp;Is this where you are receiving ERRNO -95? What happens if you add the printk in the main loop after calling client_init()?&lt;/p&gt;
[quote user=""]Error -95 is not documented in NRF, but I found that it might be&amp;nbsp;&lt;span&gt;EOPNOTSUPP&lt;/span&gt;[/quote]
&lt;p&gt;&amp;nbsp;Yes, this looks correct. As you have CONFIG_NEWLIB_LIBC=y in prj.conf, the error number is most likely &lt;a href="https://github.com/eblot/newlib/blob/master/newlib/libc/include/sys/errno.h#L131"&gt;EOPNOTSUPP&lt;/a&gt;&amp;nbsp;(&lt;span&gt;Operation not supported on transport endpoint).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Kind regards,&lt;br /&gt;Øyvind&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>