<?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>NB-IoT connection lost while keeping MQTT alive</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/48029/nb-iot-connection-lost-while-keeping-mqtt-alive</link><description>Hi, 
 I&amp;#39;m having issues maintain the connection to a MQTT server. I&amp;#39;m able to establish the connection, keeping this alive and pub/sub some massages, but after some time (~5 min) the client disconnects. After this happens I&amp;#39;m usually unable to immediately</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 17 Jul 2019 12:25:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/48029/nb-iot-connection-lost-while-keeping-mqtt-alive" /><item><title>RE: NB-IoT connection lost while keeping MQTT alive</title><link>https://devzone.nordicsemi.com/thread/198969?ContentTypeID=1</link><pubDate>Wed, 17 Jul 2019 12:25:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1dcb3b6a-160f-4fcd-bd27-900bd722dd1a</guid><dc:creator>Vojislav</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;Can you explain how would you handle reconnection? I am having trouble reconnecting to the server.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Voja.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NB-IoT connection lost while keeping MQTT alive</title><link>https://devzone.nordicsemi.com/thread/195609?ContentTypeID=1</link><pubDate>Mon, 01 Jul 2019 11:29:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:043f89f2-c070-467a-8f8a-2391854412ec</guid><dc:creator>mschweig</dc:creator><description>&lt;p&gt;Hi, how do you handle the reconnection?&amp;nbsp;&lt;br /&gt;Where do you call the functions?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NB-IoT connection lost while keeping MQTT alive</title><link>https://devzone.nordicsemi.com/thread/191924?ContentTypeID=1</link><pubDate>Tue, 11 Jun 2019 07:23:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:84773ead-d124-4989-b07b-9710dc56c030</guid><dc:creator>men</dc:creator><description>&lt;p&gt;Hi John,&lt;/p&gt;
&lt;p&gt;I dont&amp;#39;t think this is the issue, because the same happens with Azure IOT hub where I have a unique client ID.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NB-IoT connection lost while keeping MQTT alive</title><link>https://devzone.nordicsemi.com/thread/191736?ContentTypeID=1</link><pubDate>Sat, 08 Jun 2019 20:54:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4366f91d-b317-4c15-8077-09fac6c9d707</guid><dc:creator>John</dc:creator><description>&lt;p&gt;Can I make a suggestion, I read the iot.eclipse.org will disconnect anyone that has the same Client ID.&lt;/p&gt;
&lt;p&gt;Try changing my-client-id to something more obscure, that&amp;#39;s potentially unlikely to be used by someone else.&lt;/p&gt;
&lt;p&gt;Do the same with the client that is publishing the data as well, but make it different as well.&lt;/p&gt;
&lt;p&gt;# Appliaction&lt;br /&gt;#CONFIG_MQTT_PUB_TOPIC=&amp;quot;/my/publish/topic&amp;quot;&lt;br /&gt;#CONFIG_MQTT_SUB_TOPIC=&amp;quot;/my/subscribe/topic&amp;quot;&lt;br /&gt;#CONFIG_MQTT_CLIENT_ID=&amp;quot;my-client-id&amp;quot;&lt;br /&gt;#CONFIG_MQTT_BROKER_HOSTNAME=&amp;quot;iot.eclipse.org&amp;quot;&lt;br /&gt;#CONFIG_MQTT_BROKER_PORT=1883&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If I&amp;#39;m right you would be dumped the moment someone else comes along and connects to iot.eclipse.org with&lt;/p&gt;
&lt;p&gt;&lt;span&gt;#CONFIG_MQTT_CLIENT_ID=&amp;quot;my-client-id&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Love t know if I&amp;#39;m correct.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NB-IoT connection lost while keeping MQTT alive</title><link>https://devzone.nordicsemi.com/thread/191642?ContentTypeID=1</link><pubDate>Fri, 07 Jun 2019 12:11:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb7de2bc-f869-424d-897a-ea2150f28d21</guid><dc:creator>men</dc:creator><description>&lt;p&gt;Hi H&amp;aring;kon,&lt;/p&gt;
&lt;p&gt;RSRP on my board is -116 dBm. On the Evalkit&amp;nbsp;RSRP -82 dBm and the connection is not lost. It must be my antenna. :-(&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NB-IoT connection lost while keeping MQTT alive</title><link>https://devzone.nordicsemi.com/thread/191347?ContentTypeID=1</link><pubDate>Thu, 06 Jun 2019 12:16:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e194ea5-f65a-441f-9e4e-4013021e1977</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I tested this, by letting it stand there and it disconnected from the broker after a while:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;***** Booting Zephyr OS v1.14.99-ncs1 *****
The MQTT simple sample started
LTE Link Connecting ...
LTE Link Connected!
IPv4 Address found 0x106abb25
[mqtt_evt_handler:166] MQTT client connected!
Subscribing to: my/subscribe/topic len 18
[mqtt_evt_handler:216] SUBACK packet id: 1234
[mqtt_evt_handler:172] MQTT client disconnected -45
POLLNVAL
Disconnecting MQTT client...
Could not disconnect MQTT client. Error: -57
IPv4 Address found 0x106abb25&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;However, it still maintained the network connection, and&amp;nbsp;successfully ran the getaddrinfo() function.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I suspect that your device lost the network connection. Could you try with at_client and check your signal strength (last parameter of AT+CESQ)?&lt;/p&gt;
&lt;p&gt;It should return:&lt;/p&gt;
&lt;p&gt;AT+CESQ&lt;br /&gt;+CESQ: 99,99,255,255,255,&lt;em&gt;&lt;span style="text-decoration:underline;"&gt;46&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;OK&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;RSRP = -140 + 46 = -94 dBm signal strength at my end. Not great, but not bad either. 10 to 15 dB away from the receiver sensitivity.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NB-IoT connection lost while keeping MQTT alive</title><link>https://devzone.nordicsemi.com/thread/191012?ContentTypeID=1</link><pubDate>Wed, 05 Jun 2019 08:51:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b169103-7c58-4e2a-9226-82894e4a140e</guid><dc:creator>men</dc:creator><description>&lt;p&gt;Hi H&amp;aring;kon,&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve tested with &amp;quot;test.mosquitto.org&amp;quot; but it is the same result, after some time the client gets disconnected.&lt;/p&gt;
&lt;p&gt;I suspect the problem leis with the LTE connection. This time I try to get the IP of google.com. At first it is successful and so the connection to &amp;quot;test.mosquitto.org&amp;quot;, but when disconnected I&amp;#39;m unable to get IP of google.com:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;The MQTT simple sample started
LTE Link Connecting ...
LTE Link Connected!
Testing connection to &amp;quot;google.com&amp;quot;
OK: getaddrinfo success
IPv4 Address found 0x106abb25
[mqtt_evt_handler:166] MQTT client connected!
[mqtt_evt_handler:177] MQTT client disconnected -45
POLLNVAL
Disconnecting MQTT client...
Could not disconnect MQTT client. Error: -57
Testing connection to &amp;quot;google.com&amp;quot;
ERROR: getaddrinfo failed 60&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NB-IoT connection lost while keeping MQTT alive</title><link>https://devzone.nordicsemi.com/thread/190805?ContentTypeID=1</link><pubDate>Tue, 04 Jun 2019 13:55:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:01a2b666-3aba-44db-a37d-fd488821f4fc</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I agree that there&amp;#39;s some cases here that isn&amp;#39;t handled well in the application.&amp;nbsp;When getting disconnected, the application will not try to reconnect for instance.&lt;/p&gt;
&lt;p&gt;iot.eclipse.org isn&amp;#39;t always the most stable broker, as there&amp;#39;s alot of traffic going through that broker. Could you try test.mosquitto.org and see if this one also has stability issues?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NB-IoT connection lost while keeping MQTT alive</title><link>https://devzone.nordicsemi.com/thread/190739?ContentTypeID=1</link><pubDate>Tue, 04 Jun 2019 11:05:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb46eb5e-e7e2-403c-b5b1-1a44974b5cf6</guid><dc:creator>men</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/jbrzozoski"&gt; jbrzozoski,&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Yes I agree, I should be handling the reconnect in a more gentle manner. But the initial problem is that the client gets disconnected from the MQTT server.&lt;/p&gt;
&lt;p&gt;I have also tested this with Nordic MQTT sample-code and get the same result, after about 5 min the clients gets disconnected:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;The MQTT simple sample started
LTE Link Connecting ...
LTE Link Connected!
IPv4 Address found 0xf11e29c6
[mqtt_evt_handler:166] MQTT client connected!
[mqtt_evt_handler:177] MQTT client disconnected -45
POLLNVAL
Disconnecting MQTT client...
Could not disconnect MQTT client. Error: -57&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This is the content of prj.conf:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;# General config
CONFIG_TEST_RANDOM_GENERATOR=y

# Networking
CONFIG_NETWORKING=y
CONFIG_NET_SOCKETS_OFFLOAD=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y

# LTE link control
CONFIG_LTE_LINK_CONTROL=y
CONFIG_LTE_AUTO_INIT_AND_CONNECT=n
CONFIG_LTE_NETWORK_MODE_LTE_M=n
CONFIG_LTE_NETWORK_MODE_NBIOT=y
CONFIG_LTE_LEGACY_PCO_MODE=y

# BSD library
CONFIG_BSD_LIBRARY=y

# AT Host
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_AT_HOST_LIBRARY=y

# MQTT
CONFIG_MQTT_LIB=y
CONFIG_MQTT_LIB_TLS=n

# Appliaction
#CONFIG_MQTT_PUB_TOPIC=&amp;quot;/my/publish/topic&amp;quot;
#CONFIG_MQTT_SUB_TOPIC=&amp;quot;/my/subscribe/topic&amp;quot;
#CONFIG_MQTT_CLIENT_ID=&amp;quot;my-client-id&amp;quot;
#CONFIG_MQTT_BROKER_HOSTNAME=&amp;quot;iot.eclipse.org&amp;quot;
#CONFIG_MQTT_BROKER_PORT=1883

# Main thread
CONFIG_MAIN_THREAD_PRIORITY=7
CONFIG_MAIN_STACK_SIZE=4096

CONFIG_HEAP_MEM_POOL_SIZE=1024
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NB-IoT connection lost while keeping MQTT alive</title><link>https://devzone.nordicsemi.com/thread/190321?ContentTypeID=1</link><pubDate>Fri, 31 May 2019 15:17:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a046d084-ea98-49a5-91cd-8eeb142b1705</guid><dc:creator>jbrzozoski</dc:creator><description>&lt;p&gt;That -114 is errno&amp;nbsp;EALREADY.&amp;nbsp; In my testing w/ LTE-M, the MQTT/socket libraries seemed fragile if I pounded on them too much while there was already an outstanding connection request.&amp;nbsp; It was easy enough to remember if my device had an outstanding request and hold off if so.&amp;nbsp; You may want to try the same thing.&amp;nbsp; Just be sure to keep calling mqtt_input() while waiting for the connection to complete, since it needs to handle connection handshaking.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>