<?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>Can&amp;#39;t reconnect to MQTTSN gateway</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/49206/can-t-reconnect-to-mqttsn-gateway</link><description>I have been running a mqttsn client publisher/subscriber project (based on the example) successfully for some months. I have added a mosquitto broker to the raspberry pi border router. Each thread node publishes data every 10 seconds. 
 SDK: nRF5_SDK_for_Thread_and</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 07 Nov 2019 19:58:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/49206/can-t-reconnect-to-mqttsn-gateway" /><item><title>RE: Can't reconnect to MQTTSN gateway</title><link>https://devzone.nordicsemi.com/thread/219165?ContentTypeID=1</link><pubDate>Thu, 07 Nov 2019 19:58:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed48b452-6eab-4a1b-93d1-04e0182f6bc5</guid><dc:creator>Mary</dc:creator><description>&lt;p&gt;I was able to download and compile the latest MQTTSN-Gateway.&amp;nbsp; This solved my problem.&amp;nbsp; I was able to have a node reboot every 10 seconds and successfully reconnect for several hours.&lt;/p&gt;
&lt;p&gt;Instructions for compiling the MQTTSN-Gateway are &lt;a href="https://github.com/eclipse/paho.mqtt-sn.embedded-c/tree/master/MQTTSNGateway"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s what I did:&lt;/p&gt;
&lt;p&gt;Before compiling on the RaspberryPi, first install ssl-dev.&amp;nbsp; This adds header files, etc so you can compile OpenSSL dependent code..&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;$ sudo apt-get update
$ sudo apt-get install libssl-dev
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Create a working directory.&amp;nbsp; I used /home/pi/Projects.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Next, build the gateway:&lt;pre class="ui-code" data-mode="text"&gt;$ cd ~
$ mkdir Projects
$ cd Projects
$ git clone -b experiment https://github.com/eclipse/paho.mqtt-sn.embedded-c   
$ cd paho.mqtt-sn.embedded-c/MQTTSNGateway       
$ make SENSORNET=udp6 
$ make install INSTALL_DIR=/home/pi/Projects/MQTTSNGateway_v1.3.1 CONFIG_DIR=/home/pi/Projects/MQTTSNGateway_v1.3.1   
$ make clean    
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Stop the currently running gateway:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;$ sudo systemctl stop paho-mqttsn-gateway.service&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Edit the service file:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;$ sudo nano /etc/systemd/system/paho-mqttsn-gateway.service&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Change the ExecStart line to explicitly specify the configuration file:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;ExecStart=/usr/sbin/MQTT-SNGateway -f /etc/paho-mqtt-sn-gateway.conf&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Copy the predefinedTopics.conf file from the CONFIG_DIR to /etc or add a new file for predefined topics and edit as needed.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;$ sudo nano /etc/predefinedTopic.conf&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Make a backup of the original executable and copy the new one to /usr/sbin:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;$ sudo cp /usr/sbin/MQTT-SNGateway /usr/sbin/MQTT-SNGateway_v1.0.1

$ sudo cp /home/pi/Projects/MQTTSNGateway_v1.3.1/MQTT-SNGateway /usr/sbin/MQTT-SNGateway

$ make clean
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Restart the gateway:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;$ sudo systemctl start paho-mqttsn-gateway.service&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Viewing the systemd log will show the gateway activity.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;$ journalctl -ef&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't reconnect to MQTTSN gateway</title><link>https://devzone.nordicsemi.com/thread/210986?ContentTypeID=1</link><pubDate>Fri, 20 Sep 2019 14:34:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:031344cc-94f0-47fe-ba3d-a743fd2d1f12</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;Still waiting on reply from the development team.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't reconnect to MQTTSN gateway</title><link>https://devzone.nordicsemi.com/thread/210486?ContentTypeID=1</link><pubDate>Wed, 18 Sep 2019 15:10:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75887a21-2765-4491-b038-831003076b96</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;Sorry for the late reply, I&amp;#39;ve been out of office for a while.&lt;/p&gt;
&lt;p&gt;I have forwarded this to our development team to get some assistance from them.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't reconnect to MQTTSN gateway</title><link>https://devzone.nordicsemi.com/thread/209654?ContentTypeID=1</link><pubDate>Fri, 13 Sep 2019 13:39:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:038ead00-cfa8-4edb-a5ee-36fa9204630a</guid><dc:creator>Mary</dc:creator><description>&lt;p&gt;Yes, as I mentioned above.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve also looked at the MQTT-SNGateway code at github.&amp;nbsp; There&amp;#39;s a limit of 100 connections, after that no more can be accepted.&amp;nbsp; The current version of the software provides for re-using a connection when a device re-connects after a disconnection.&amp;nbsp; I wonder if this provision is missing in the 1.0.1 version that is installed on the 3.1.0 Border Router, such that after 100 Thread device reboots all connections fail.&lt;/p&gt;
&lt;p&gt;I&amp;#39;d like to try the latest version of MQTT-SNGateway, and just wanted some guidance on how to do that without breaking anything.&lt;/p&gt;
&lt;p&gt;Mary&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't reconnect to MQTTSN gateway</title><link>https://devzone.nordicsemi.com/thread/209518?ContentTypeID=1</link><pubDate>Fri, 13 Sep 2019 05:45:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3082c095-107a-4662-878e-41f56bc59a56</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;Have you tried to update to the latest &lt;a href="https://www.nordicsemi.com/Software-and-Tools/Software/nRF5-SDK-for-Thread-and-Zigbee/Download#infotabs"&gt;SDK, 3.1.0&lt;/a&gt;?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't reconnect to MQTTSN gateway</title><link>https://devzone.nordicsemi.com/thread/209268?ContentTypeID=1</link><pubDate>Wed, 11 Sep 2019 18:48:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a5609c6e-17ec-4bf2-a0ae-d45300cbd265</guid><dc:creator>Mary</dc:creator><description>&lt;p&gt;I&amp;#39;m wondering if just updating to the latest version of MQTT-SNGateway would help.&amp;nbsp; Can you provide me with instructions on how to do that?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't reconnect to MQTTSN gateway</title><link>https://devzone.nordicsemi.com/thread/197331?ContentTypeID=1</link><pubDate>Tue, 09 Jul 2019 10:54:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fbb08a28-36ad-4bbf-8ba6-3cc0c7a3c2c2</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi Mary.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve forwarded your latest reply to our developers, I have to wait and see what they come up with. Note that it is holiday season so it might take some time.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't reconnect to MQTTSN gateway</title><link>https://devzone.nordicsemi.com/thread/197201?ContentTypeID=1</link><pubDate>Mon, 08 Jul 2019 16:06:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:04b4d3fc-431e-490b-bb51-745500f7326a</guid><dc:creator>Mary</dc:creator><description>&lt;p&gt;Thanks.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Today, I installed the latest Border Router on the raspberry pi,3.1.0 and the same thing happened.&amp;nbsp;&amp;nbsp;The gateway starts refusing connections after the repeated re-connects from &lt;span&gt;Dalcc970a4319322c55&amp;nbsp;&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;MQTT-SNGateway is version 1.01&lt;/p&gt;
&lt;p&gt;I searched for the error message &amp;quot;CONNECT message has been discarded&amp;quot; and found it &lt;a href="https://github.com/eclipse/paho.mqtt-sn.embedded-c/issues/53"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The discussion includes this code snippet from &lt;span&gt;MQTTSNGWClientRecvTask.cpp&lt;/span&gt;:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;                /* create a client */
				client = _gateway-&amp;gt;getClientList()-&amp;gt;createClient(_sensorNetwork-&amp;gt;getSenderAddress(), &amp;amp;data.clientID, false, false);
				log(client, packet, &amp;amp;data.clientID);
				if (!client)
				{
                                        //char buf[128]; 
					WRITELOG(&amp;quot;%s Client(%s) was rejected. CONNECT message has been discarded.%s\n&amp;quot;, ERRMSG_HEADER, _sensorNetwork-&amp;gt;getSenderAddress()-&amp;gt;sprint(buf), ERRMSG_FOOTER);
					delete packet;
					continue;
				}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;It apparently is unable to create a new client, but I have no idea why.&lt;/p&gt;
&lt;p&gt;Mary&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't reconnect to MQTTSN gateway</title><link>https://devzone.nordicsemi.com/thread/197151?ContentTypeID=1</link><pubDate>Mon, 08 Jul 2019 13:16:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b603aea-5d56-49cd-bc5a-e5b21fb7fa85</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;This requires some digging, I have asked if our developer team can take a look at it if that&amp;#39;s ok for you.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't reconnect to MQTTSN gateway</title><link>https://devzone.nordicsemi.com/thread/196890?ContentTypeID=1</link><pubDate>Fri, 05 Jul 2019 15:31:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2bd26fbe-f30b-43c3-87a9-601cf8e9efd9</guid><dc:creator>Mary</dc:creator><description>&lt;p&gt;I have reproduce the problem.&lt;/p&gt;
&lt;p&gt;I am at the moment testing the watchdog timer function.&amp;nbsp; To test the timeout function, I comment out the call to feed the watchdog timer so that the timeout and reset occurs after 5 seconds.&amp;nbsp; This happens repeatedly.&amp;nbsp; So, it&amp;#39;s rebooting and reconnecting to the mqttsn gateway every 5 seconds.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;After a while the gateway starts rejecting the connection.&amp;nbsp; The attached file shows the mqttsn gateway log:&lt;/p&gt;
&lt;p&gt;Client &amp;quot;Dal2599e811bfb8c985&amp;quot;&amp;nbsp; is running continuously without rebooting.&lt;/p&gt;
&lt;p&gt;Client &amp;quot;Dalcc970a4319322c55&amp;nbsp;&amp;quot; is rebooting after 5 seconds.&lt;/p&gt;
&lt;p&gt;See line 1282 for the first client rejection.&lt;/p&gt;
&lt;p&gt;Further down (line 1381), even the node that is not rebooting gets rejected&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/mqtt_2D00_gateway_5F00_log_5F00_connect_5F00_rejected.txt"&gt;devzone.nordicsemi.com/.../mqtt_2D00_gateway_5F00_log_5F00_connect_5F00_rejected.txt&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I know this is not a realistic scenario, but I&amp;#39;d like to know why the gateway starts rejecting ANY connection.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The only recovery is to stop and restart the gateway.&lt;/p&gt;
&lt;p&gt;Mary&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't reconnect to MQTTSN gateway</title><link>https://devzone.nordicsemi.com/thread/196407?ContentTypeID=1</link><pubDate>Thu, 04 Jul 2019 08:01:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8cfb5b5b-a4e4-4be3-99ab-685d8f1bfbae</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;Great to hear that it is working :-)&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't reconnect to MQTTSN gateway</title><link>https://devzone.nordicsemi.com/thread/196056?ContentTypeID=1</link><pubDate>Tue, 02 Jul 2019 15:45:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e7f545c6-66c5-4dbe-8bdb-fe451a33d814</guid><dc:creator>Mary</dc:creator><description>&lt;p&gt;I stopped and restarted mosquitto:&lt;/p&gt;
&lt;p&gt;/etc/init.d/mosquitto stop&lt;/p&gt;
&lt;p&gt;/etc/init.d/mosquitto start&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;then restarted the gateway:&lt;/p&gt;
&lt;p&gt;sudo /usr/sbin/MQTT-SNGateway -f paho-mqtt-sn-gateway.conf &amp;amp;&lt;/p&gt;
&lt;p&gt;and it ran.&lt;/p&gt;
&lt;p&gt;Message publishing is now restored, (but all the messages from the gateway are printing to my raspberry pi console.)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't reconnect to MQTTSN gateway</title><link>https://devzone.nordicsemi.com/thread/196030?ContentTypeID=1</link><pubDate>Tue, 02 Jul 2019 14:08:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c509525f-f821-41a2-bb1c-df6e712d68a6</guid><dc:creator>Mary</dc:creator><description>&lt;p&gt;I tried killing the MQTT-SNGateway:&lt;/p&gt;
&lt;p&gt;sudo kill -9 &amp;lt;PID&amp;gt;&lt;/p&gt;
&lt;p&gt;then restar it:&lt;/p&gt;
&lt;p&gt;/usr/sbin/MQTT-SNGateway&lt;/p&gt;
&lt;p&gt;but got an error:&lt;/p&gt;
&lt;p&gt;pi@raspberrypi:/etc/init.d $ /usr/sbin/MQTT-SNGateway&lt;br /&gt;terminate called after throwing an instance of &amp;#39;MQTTSNGW::Exception&amp;#39;&lt;br /&gt; what(): Semaphore can&amp;#39;t be created.&lt;br /&gt;Aborted&lt;/p&gt;
&lt;p&gt;I will have to reboot.&amp;nbsp; I will also download the latest image.&lt;/p&gt;
&lt;p&gt;Mary&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't reconnect to MQTTSN gateway</title><link>https://devzone.nordicsemi.com/thread/195850?ContentTypeID=1</link><pubDate>Tue, 02 Jul 2019 08:10:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd0b5ef6-af78-406e-8200-3d7456b17439</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi Mary.&lt;/p&gt;
&lt;p&gt;We have a new SDK and a new border router I suggest that you start using, you can download both &lt;a href="https://www.nordicsemi.com/Software-and-Tools/Software/nRF5-SDK-for-Thread-and-Zigbee/Download#infotabs"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;About your issue:&lt;/p&gt;
&lt;p&gt;Could you try to restart the MQTT-SN Gateway (only the gateway, not the whole Raspberry PI) when this issue occurs, so that we can check if the problem is still there? Should this help you the problem is likely somewhere in the gateway. If this does not work, could you try to restart mosquitto?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>