This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

MQTT Socket error after 4 consecutive MQTT connect/disconnect

Hi,

we are using MQTT to push the sensor and GPS data with 1 hour interval. After 4 consecutive connect and disconnect, MQTT is returning socket error. It requires the device reboot to connect again, so rebooting the device after every 4 MQTT connections. Because of reboot the device is taking longer time to get GPS fix for first time.

It is 100% reproducible. we are using our own MQTT broker and also tried the other brokers as well and behavior is same.

Error log returned by MQTT is "ERROR: mqtt_connect -12".

Please help us to resolve the issue.

Parents
  • Hi.

    I'll need a bit more information in order to help you:

    1. What version (tag/commit of the nrf repo) are you using, and what version of the modem firmware?

    2. What kind of MQTT broker are you connecting to? AWS? Some other cloud solution? Something else?

    3. Are you certain that you are connected to the network, and that you have re-initialized the MQTT client properly when you fail to reconnect?

    4. Is it always the third time you connect to the MQTT broker that fails?

    Best regards,

    Didrik

  • Hi,

    please find my answers.

    1. What version (tag/commit of the nrf repo) are you using, and what version of the modem firmware?

    -Tested in Tag:V1.0 and V1.1.0(currently using), issue is consistent in both.

    -Modem firmware latest 1.1.0

    2. What kind of MQTT broker are you connecting to? AWS? Some other cloud solution? Something else?

    -Tested with our AWS broker and also ellipse mosquito broker, issue is consistently reproducible.

    3. Are you certain that you are connected to the network, and that you have re-initialized the MQTT client properly when you fail to reconnect?

    -Yes, tested using CEREG command and it says connected.

    Application disconnects the MQTT properly and 4th time connect is retuning error.

    4. Is it always the third time you connect to the MQTT broker that fails?

    - yes always gets error  on 4th connect.

    If required i can share you the modified simple mqtt application to reproduce the issue on your side.

Reply
  • Hi,

    please find my answers.

    1. What version (tag/commit of the nrf repo) are you using, and what version of the modem firmware?

    -Tested in Tag:V1.0 and V1.1.0(currently using), issue is consistent in both.

    -Modem firmware latest 1.1.0

    2. What kind of MQTT broker are you connecting to? AWS? Some other cloud solution? Something else?

    -Tested with our AWS broker and also ellipse mosquito broker, issue is consistently reproducible.

    3. Are you certain that you are connected to the network, and that you have re-initialized the MQTT client properly when you fail to reconnect?

    -Yes, tested using CEREG command and it says connected.

    Application disconnects the MQTT properly and 4th time connect is retuning error.

    4. Is it always the third time you connect to the MQTT broker that fails?

    - yes always gets error  on 4th connect.

    If required i can share you the modified simple mqtt application to reproduce the issue on your side.

Children
  • Balamurugan said:
    If required i can share you the modified simple mqtt application to reproduce the issue on your side.

     Yes please, that would be very helpful.

  • Hi,

    I have attached the modified sample MQTT application to reproduce the issue, UART Log and mqtt settings.

    we are using IPV6 and NB NW.

    Please help us to resolve the issue.

    /*
     * Copyright (c) 2018 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
     */
    
    #include <zephyr.h>
    #include <stdio.h>
    #include <uart.h>
    #include <string.h>
    
    #include <net/mqtt.h>
    #include <net/socket.h>
    #include <lte_lc.h>
    #if defined(CONFIG_LWM2M_CARRIER)
    #include <lwm2m_carrier.h>
    #endif
    
    /* Buffers for MQTT client. */
    static u8_t rx_buffer[CONFIG_MQTT_MESSAGE_BUFFER_SIZE];
    static u8_t tx_buffer[CONFIG_MQTT_MESSAGE_BUFFER_SIZE];
    static u8_t payload_buf[CONFIG_MQTT_PAYLOAD_BUFFER_SIZE];
    
    /* The mqtt client struct */
    static struct mqtt_client client;
    
    /* MQTT Broker details. */
    static struct sockaddr_storage broker_storage;
    
    /* Connected flag */
    static bool connected;
    
    /* File descriptor */
    static struct pollfd fds;
    
    
    #if defined(CONFIG_BSD_LIBRARY)
    
    /**@brief Recoverable BSD library error. */
    void bsd_recoverable_error_handler(uint32_t err)
    {
    	printk("bsdlib recoverable error: %u\n", (unsigned int)err);
    }
    
    #endif /* defined(CONFIG_BSD_LIBRARY) */
    
    #if defined(CONFIG_LWM2M_CARRIER)
    K_SEM_DEFINE(carrier_registered, 0, 1);
    
    void lwm2m_carrier_event_handler(const lwm2m_carrier_event_t *event)
    {
    	switch (event->type) {
    	case LWM2M_CARRIER_EVENT_BSDLIB_INIT:
    		printk("LWM2M_CARRIER_EVENT_BSDLIB_INIT\n");
    		break;
    	case LWM2M_CARRIER_EVENT_CONNECT:
    		printk("LWM2M_CARRIER_EVENT_CONNECT\n");
    		break;
    	case LWM2M_CARRIER_EVENT_DISCONNECT:
    		printk("LWM2M_CARRIER_EVENT_DISCONNECT\n");
    		break;
    	case LWM2M_CARRIER_EVENT_READY:
    		printk("LWM2M_CARRIER_EVENT_READY\n");
    		k_sem_give(&carrier_registered);
    		break;
    	case LWM2M_CARRIER_EVENT_FOTA_START:
    		printk("LWM2M_CARRIER_EVENT_FOTA_START\n");
    		break;
    	case LWM2M_CARRIER_EVENT_REBOOT:
    		printk("LWM2M_CARRIER_EVENT_REBOOT\n");
    		break;
    	}
    }
    #endif /* defined(CONFIG_LWM2M_CARRIER) */
    
    /**@brief Function to print strings without null-termination
     */
    static void data_print(u8_t *prefix, u8_t *data, size_t len)
    {
    	char buf[len + 1];
    
    	memcpy(buf, data, len);
    	buf[len] = 0;
    	printk("%s%s\n", prefix, buf);
    }
    
    /**@brief Function to publish data on the configured topic
     */
    static int data_publish(struct mqtt_client *c, enum mqtt_qos qos,
    	u8_t *data, size_t len)
    {
    	struct mqtt_publish_param param;
    
    	param.message.topic.qos = qos;
    	param.message.topic.topic.utf8 = CONFIG_MQTT_PUB_TOPIC;
    	param.message.topic.topic.size = strlen(CONFIG_MQTT_PUB_TOPIC);
    	param.message.payload.data = data;
    	param.message.payload.len = len;
    	param.message_id = sys_rand32_get();
    	param.dup_flag = 0;
    	param.retain_flag = 0;
    
    	data_print("Publishing: ", data, len);
    	printk("to topic: %s len: %u\n",
    		CONFIG_MQTT_PUB_TOPIC,
    		(unsigned int)strlen(CONFIG_MQTT_PUB_TOPIC));
    
    	return mqtt_publish(c, &param);
    }
    
    /**@brief Function to subscribe to the configured topic
     */
    static int subscribe(void)
    {
    	struct mqtt_topic subscribe_topic = {
    		.topic = {
    			.utf8 = CONFIG_MQTT_SUB_TOPIC,
    			.size = strlen(CONFIG_MQTT_SUB_TOPIC)
    		},
    		.qos = MQTT_QOS_1_AT_LEAST_ONCE
    	};
    
    	const struct mqtt_subscription_list subscription_list = {
    		.list = &subscribe_topic,
    		.list_count = 1,
    		.message_id = 1234
    	};
    
    	printk("Subscribing to: %s len %u\n", CONFIG_MQTT_SUB_TOPIC,
    		(unsigned int)strlen(CONFIG_MQTT_SUB_TOPIC));
    
    	return mqtt_subscribe(&client, &subscription_list);
    }
    
    /**@brief Function to read the published payload.
     */
    static int publish_get_payload(struct mqtt_client *c, size_t length)
    {
    	u8_t *buf = payload_buf;
    	u8_t *end = buf + length;
    
    	if (length > sizeof(payload_buf)) {
    		return -EMSGSIZE;
    	}
    
    	while (buf < end) {
    		int ret = mqtt_read_publish_payload(c, buf, end - buf);
    
    		if (ret < 0) {
    			int err;
    
    			if (ret != -EAGAIN) {
    				return ret;
    			}
    
    			printk("mqtt_read_publish_payload: EAGAIN\n");
    
    			err = poll(&fds, 1, K_SECONDS(CONFIG_MQTT_KEEPALIVE));
    			if (err > 0 && (fds.revents & POLLIN) == POLLIN) {
    				continue;
    			} else {
    				return -EIO;
    			}
    		}
    
    		if (ret == 0) {
    			return -EIO;
    		}
    
    		buf += ret;
    	}
    
    	return 0;
    }
    
    /**@brief MQTT client event handler
     */
    void mqtt_evt_handler(struct mqtt_client *const c,
    		      const struct mqtt_evt *evt)
    {
    	int err;
    
    	switch (evt->type) {
    	case MQTT_EVT_CONNACK:
    		if (evt->result != 0) {
    			printk("MQTT connect failed %d\n", evt->result);
    			break;
    		}
    
    		connected = true;
    		printk("[%s:%d] MQTT client connected!\n", __func__, __LINE__);
    		//subscribe();
    		break;
    
    	case MQTT_EVT_DISCONNECT:
    		printk("[%s:%d] MQTT client disconnected %d\n", __func__,
    		       __LINE__, evt->result);
    
    		connected = false;
    		break;
    
    	case MQTT_EVT_PUBLISH: {
    		const struct mqtt_publish_param *p = &evt->param.publish;
    
    		printk("[%s:%d] MQTT PUBLISH result=%d len=%d\n", __func__,
    		       __LINE__, evt->result, p->message.payload.len);
    		err = publish_get_payload(c, p->message.payload.len);
    		if (err >= 0) {
    			data_print("Received: ", payload_buf,
    				p->message.payload.len);
    			/* Echo back received data */
    			data_publish(&client, MQTT_QOS_1_AT_LEAST_ONCE,
    				payload_buf, p->message.payload.len);
    		} else {
    			printk("mqtt_read_publish_payload: Failed! %d\n", err);
    			printk("Disconnecting MQTT client...\n");
    
    			err = mqtt_disconnect(c);
    			if (err) {
    				printk("Could not disconnect: %d\n", err);
    			}
    		}
    	} break;
    
    	case MQTT_EVT_PUBACK:
    		if (evt->result != 0) {
    			printk("MQTT PUBACK error %d\n", evt->result);
    			break;
    		}
    
    		printk("[%s:%d] PUBACK packet id: %u\n", __func__, __LINE__,
    				evt->param.puback.message_id);
    		break;
    
    	case MQTT_EVT_SUBACK:
    		if (evt->result != 0) {
    			printk("MQTT SUBACK error %d\n", evt->result);
    			break;
    		}
    
    		printk("[%s:%d] SUBACK packet id: %u\n", __func__, __LINE__,
    				evt->param.suback.message_id);
    		break;
    
    	default:
    		printk("[%s:%d] default: %d\n", __func__, __LINE__,
    				evt->type);
    		break;
    	}
    }
    
    
    /**@brief Resolves the configured hostname and
     * initializes the MQTT broker structure
     */
    static void broker_init(void)
    {
            int err;
    	struct addrinfo *result;
    	struct addrinfo *addr;
    	struct addrinfo hints = {
    		.ai_family = AF_INET6,
    		.ai_socktype = SOCK_STREAM
    	};
    
           
            k_sleep(K_SECONDS(3));
    
    	err = getaddrinfo(CONFIG_MQTT_BROKER_HOSTNAME, NULL, &hints, &result);
    	if (err) {
    		printk("ERROR: getaddrinfo failed %d\n", err);
    
    		return;
    	}
    
    	addr = result;
    	err = -ENOENT;
    
    	while (addr != NULL) {
    		/* IPv4 Address. */
    		if (addr->ai_addrlen == sizeof(struct sockaddr_in)) {
    			struct sockaddr_in *broker =
    				((struct sockaddr_in *)&broker_storage);
    
    			broker->sin_addr.s_addr =
    				((struct sockaddr_in *)addr->ai_addr)
    				->sin_addr.s_addr;
    			broker->sin_family = AF_INET;
    			broker->sin_port = htons(CONFIG_MQTT_BROKER_PORT);
    
    			printk("IPv4 Address 0x%08x\n", broker->sin_addr.s_addr);
    			break;
    		} else if (addr->ai_addrlen == sizeof(struct sockaddr_in6)) {
    			/* IPv6 Address. */
    			struct sockaddr_in6 *broker =
    				((struct sockaddr_in6 *)&broker_storage);
    
    			memcpy(broker->sin6_addr.s6_addr,
    				((struct sockaddr_in6 *)addr->ai_addr)
    				->sin6_addr.s6_addr,
    				sizeof(struct in6_addr));
    			broker->sin6_family = AF_INET6;
    			broker->sin6_port = htons(CONFIG_MQTT_BROKER_PORT);
    
    			printk("IPv6 Address %s \n",CONFIG_MQTT_BROKER_HOSTNAME);
    			break;
    		} else {
    			printk("error: ai_addrlen = %u should be %u or %u\n",
    				(unsigned int)addr->ai_addrlen,
    				(unsigned int)sizeof(struct sockaddr_in),
    				(unsigned int)sizeof(struct sockaddr_in6));
    		}
    
    		addr = addr->ai_next;
    		break;
    	}
    
    	/* Free the address. */
    	freeaddrinfo(result);
    }
    
    /**@brief Initialize the MQTT client structure
     */
    static void client_init(struct mqtt_client *client)
    {
    	mqtt_client_init(client);
    
    	broker_init();
    
    	/* MQTT client configuration */
    	client->broker = &broker_storage;
    	client->evt_cb = mqtt_evt_handler;
    	client->client_id.utf8 = (u8_t *)CONFIG_MQTT_CLIENT_ID;
    	client->client_id.size = strlen(CONFIG_MQTT_CLIENT_ID);
    	client->password = NULL;
    	client->user_name = NULL;
    	client->protocol_version = MQTT_VERSION_3_1_1;
    
    	/* MQTT buffers configuration */
    	client->rx_buf = rx_buffer;
    	client->rx_buf_size = sizeof(rx_buffer);
    	client->tx_buf = tx_buffer;
    	client->tx_buf_size = sizeof(tx_buffer);
    
    	/* MQTT transport configuration */
    	client->transport.type = MQTT_TRANSPORT_NON_SECURE;
    }
    
    /**@brief Initialize the file descriptor structure used by poll.
     */
    static int fds_init(struct mqtt_client *c)
    {
    	if (c->transport.type == MQTT_TRANSPORT_NON_SECURE) {
    		fds.fd = c->transport.tcp.sock;
    	} else {
    #if defined(CONFIG_MQTT_LIB_TLS)
    		fds.fd = c->transport.tls.sock;
    #else
    		return -ENOTSUP;
    #endif
    	}
    
    	fds.events = POLLIN;
    
    	return 0;
    }
    
    /**@brief Configures modem to provide LTE link. Blocks until link is
     * successfully established.
     */
    static void modem_configure(void)
    {
    #if defined(CONFIG_LTE_LINK_CONTROL)
    	if (IS_ENABLED(CONFIG_LTE_AUTO_INIT_AND_CONNECT)) {
    		/* Do nothing, modem is already turned on
    		 * and connected.
    		 */
    	} else {
    #if defined(CONFIG_LWM2M_CARRIER)
    		/* Wait for the LWM2M_CARRIER to configure the modem and
    		 * start the connection.
    		 */
    		printk("Waitng for carrier registration...\n");
    		k_sem_take(&carrier_registered, K_FOREVER);
    		printk("Registered!\n");
    #else /* defined(CONFIG_LWM2M_CARRIER) */
    		int err;
    
    		printk("LTE Link Connecting ...\n");
    		err = lte_lc_init_and_connect();
    		__ASSERT(err == 0, "LTE link could not be established.");
    		printk("LTE Link Connected!\n");
    #endif /* defined(CONFIG_LWM2M_CARRIER) */
    	}
    #endif /* defined(CONFIG_LTE_LINK_CONTROL) */
    }
    
    void static mqttLoop()
    {
    
          int err;
          client_init(&client);
    
    	err = mqtt_connect(&client);
    	if (err != 0) {
    		printk("ERROR: mqtt_connect %d\n", err);
    		return;
    	}
    
    	err = fds_init(&client);
    	if (err != 0) {
    		printk("ERROR: fds_init %d\n", err);
    		return;
    	}
    
    	
    		err = poll(&fds, 1, K_SECONDS(CONFIG_MQTT_KEEPALIVE));
    		if (err < 0) {
    			printk("ERROR: poll %d\n", errno);
    			
    		}
    
    		err = mqtt_live(&client);
    		if (err != 0) {
    			printk("ERROR: mqtt_live %d\n", err);
    			
    		}
    
    		if ((fds.revents & POLLIN) == POLLIN) {
    			err = mqtt_input(&client);
    			if (err != 0) {
    				printk("ERROR: mqtt_input %d\n", err);
    				
    			}
    		}
    
    		if ((fds.revents & POLLERR) == POLLERR) {
    			printk("POLLERR\n");
    			
    		}
    
    		if ((fds.revents & POLLNVAL) == POLLNVAL) {
    			printk("POLLNVAL\n");
    			
    		}
                    
                    char dPayload[100];
                    sprintf(dPayload,"sample data");
                    data_publish(&client,0,dPayload,strlen(dPayload));
                    k_sleep(K_SECONDS(3));
    	
    
    	printk("Disconnecting MQTT client...\n");
    
    	err = mqtt_disconnect(&client);
    	if (err) {
    		printk("Could not disconnect MQTT client. Error: %d\n", err);
    	}
    }
    
    void main(void)
    {
    	
    
    	printk("The MQTT simple sample started\n");
    
    	modem_configure();
    
            while(true)
            {
            mqttLoop();
            k_sleep(K_SECONDS(5));
            }
    
    	
    }
    

    *** Booting Zephyr OS build v2.0.99-ncs1-rc1-1162-g9a0a85cf6760  ***
    Flash region            Domain          Permissions
    00 0x00000 0x08000      Secure          rwxl
    01 0x08000 0x10000      Non-Secure      rwxl
    02 0x10000 0x18000      Non-Secure      rwxl
    03 0x18000 0x20000      Non-Secure      rwxl
    04 0x20000 0x28000      Non-Secure      rwxl
    05 0x28000 0x30000      Non-Secure      rwxl
    06 0x30000 0x38000      Non-Secure      rwxl
    07 0x38000 0x40000      Non-Secure      rwxl
    08 0x40000 0x48000      Non-Secure      rwxl
    09 0x48000 0x50000      Non-Secure      rwxl
    10 0x50000 0x58000      Non-Secure      rwxl
    11 0x58000 0x60000      Non-Secure      rwxl
    12 0x60000 0x68000      Non-Secure      rwxl
    13 0x68000 0x70000      Non-Secure      rwxl
    14 0x70000 0x78000      Non-Secure      rwxl
    15 0x78000 0x80000      Non-Secure      rwxl
    16 0x80000 0x88000      Non-Secure      rwxl
    17 0x88000 0x90000      Non-Secure      rwxl
    18 0x90000 0x98000      Non-Secure      rwxl
    19 0x98000 0xa0000      Non-Secure      rwxl
    20 0xa0000 0xa8000      Non-Secure      rwxl
    21 0xa8000 0xb0000      Non-Secure      rwxl
    22 0xb0000 0xb8000      Non-Secure      rwxl
    23 0xb8000 0xc0000      Non-Secure      rwxl
    24 0xc0000 0xc8000      Non-Secure      rwxl
    25 0xc8000 0xd0000      Non-Secure      rwxl
    26 0xd0000 0xd8000      Non-Secure      rwxl
    27 0xd8000 0xe0000      Non-Secure      rwxl
    28 0xe0000 0xe8000      Non-Secure      rwxl
    29 0xe8000 0xf0000      Non-Secure      rwxl
    30 0xf0000 0xf8000      Non-Secure      rwxl
    31 0xf8000 0x100000     Non-Secure      rwxl
    Non-secure callable region 0 placed in flash region 0 with size 32.
    
    
    SRAM region             Domain          Permissions
    00 0x00000 0x02000      Secure          rwxl
    01 0x02000 0x04000      Secure          rwxl
    02 0x04000 0x06000      Secure          rwxl
    03 0x06000 0x08000      Secure          rwxl
    04 0x08000 0x0a000      Secure          rwxl
    05 0x0a000 0x0c000      Secure          rwxl
    06 0x0c000 0x0e000      Secure          rwxl
    07 0x0e000 0x10000      Secure          rwxl
    08 0x10000 0x12000      Non-Secure      rwxl
    09 0x12000 0x14000      Non-Secure      rwxl
    10 0x14000 0x16000      Non-Secure      rwxl
    11 0x16000 0x18000      Non-Secure      rwxl
    12 0x18000 0x1a000      Non-Secure      rwxl
    13 0x1a000 0x1c000      Non-Secure      rwxl
    14 0x1c000 0x1e000      Non-Secure      rwxl
    15 0x1e000 0x20000      Non-Secure      rwxl
    16 0x20000 0x22000      Non-Secure      rwxl
    17 0x22000 0x24000      Non-Secure      rwxl
    18 0x24000 0x26000      Non-Secure      rwxl
    19 0x26000 0x28000      Non-Secure      rwxl
    20 0x28000 0x2a000      Non-Secure      rwxl
    21 0x2a000 0x2c000      Non-Secure      rwxl
    22 0x2c000 0x2e000      Non-Secure      rwxl
    23 0x2e000 0x30000      Non-Secure      rwxl
    24 0x30000 0x32000      Non-Secure      rwxl
    25 0x32000 0x34000      Non-Secure      rwxl
    26 0x34000 0x36000      Non-Secure      rwxl
    27 0x36000 0x38000      Non-Secure      rwxl
    28 0x38000 0x3a000      Non-Secure      rwxl
    29 0x3a000 0x3c000      Non-Secure      rwxl
    30 0x3c000 0x3e000      Non-Secure      rwxl
    31 0x3e000 0x40000      Non-Secure      rwxl
    
    Peripheral              Domain          Status
    00 NRF_P0               Non-Secure      OK
    01 NRF_CLOCK            Non-Secure      OK
    02 NRF_RTC1             Non-Secure      OK
    03 NRF_NVMC             Non-Secure      OK
    04 NRF_UARTE1           Non-Secure      OK
    05 NRF_UARTE2           Secure          SKIP
    06 NRF_TWIM2            Non-Secure      OK
    07 NRF_SPIM3            Non-Secure      OK
    08 NRF_TIMER0           Non-Secure      OK
    09 NRF_TIMER1           Non-Secure      OK
    10 NRF_TIMER2           Non-Secure      OK
    11 NRF_SAADC            Non-Secure      OK
    12 NRF_PWM0             Non-Secure      OK
    13 NRF_PWM1             Non-Secure      OK
    14 NRF_PWM2             Non-Secure      OK
    15 NRF_PWM3             Non-Secure      OK
    16 NRF_WDT              Non-Secure      OK
    17 NRF_IPC              Non-Secure      OK
    18 NRF_VMC              Non-Secure      OK
    19 NRF_FPU              Non-Secure      OK
    20 NRF_EGU1             Non-Secure      OK
    21 NRF_EGU2             Non-Secure      OK
    22 NRF_DPPIC            Non-Secure      OK
    23 NRF_GPIOTE1          Non-Secure      OK
    24 NRF_REGULATORS       Secure          SKIP
    
    SPM: NS image at 0xc000
    SPM: NS MSP at 0x20024cf8
    SPM: NS reset vector at 0xddf9
    SPM: prepare to jump to Non-Secure image.
    *** Booting Zephyr OS build v2.0.99-ncs1-rc1-1162-g9a0a85cf6760  ***
    The MQTT simple sample started
    LTE Link Connecting ...
    +CEREG: 2,"0013","00436D0F",9,0,0,"11100000","11100000"
    +CEREG: 1,"0013","00436D0F",9,,,"11100000","11100000"
    LTE Link Connected!
    IPv6 Address 2406:da1a:275:8410:1bd5:1317:a239:9810
    [mqtt_evt_handler:194] MQTT client connected!
    Publishing: sample data
    to topic: tw/track len: 8
    Disconnecting MQTT client...
    IPv6 Address 2406:da1a:275:8410:1bd5:1317:a239:9810
    [mqtt_evt_handler:194] MQTT client connected!
    Publishing: sample data
    to topic: tw/track len: 8
    Disconnecting MQTT client...
    IPv6 Address 2406:da1a:275:8410:1bd5:1317:a239:9810
    [mqtt_evt_handler:194] MQTT client connected!
    Publishing: sample data
    to topic: tw/track len: 8
    Disconnecting MQTT client...
    IPv6 Address 2406:da1a:275:8410:1bd5:1317:a239:9810
    [mqtt_evt_handler:194] MQTT client connected!
    Publishing: sample data
    to topic: tw/track len: 8
    Disconnecting MQTT client...
    IPv6 Address 2406:da1a:275:8410:1bd5:1317:a239:9810
    [mqtt_evt_handler:194] MQTT client connected!
    Publishing: sample data
    to topic: tw/track len: 8
    Disconnecting MQTT client...
    IPv6 Address 2406:da1a:275:8410:1bd5:1317:a239:9810
    inside mqtt_connect -12ERROR: mqtt_connect -12
    IPv6 Address 2406:da1a:275:8410:1bd5:1317:a239:9810
    inside mqtt_connect -12ERROR: mqtt_connect -12
    IPv6 Address 2406:da1a:275:8410:1bd5:1317:a239:9810
    inside mqtt_connect -12ERROR: mqtt_connect -12
    +CEREG: 5,1,"0013","00436D0F",9,,,"11100000","11100000"
    OK
    IPv6 Address 2406:da1a:275:8410:1bd5:1317:a239:9810
    inside mqtt_connect -12ERROR: mqtt_connect -12
    *** Booting Zephyr OS build v2.0.99-ncs1-rc1-1162-g9a0a85cf6760  ***
    Flash region            Domain          Permissions
    00 0x00000 0x08000      Secure          rwxl
    01 0x08000 0x10000      Non-Secure      rwxl
    02 0x10000 0x18000      Non-Secure      rwxl
    03 0x18000 0x20000      Non-Secure      rwxl
    04 0x20000 0x28000      Non-Secure      rwxl
    05 0x28000 0x30000      Non-Secure      rwxl
    06 0x30000 0x38000      Non-Secure      rwxl
    07 0x38000 0x40000      Non-Secure      rwxl
    08 0x40000 0x48000      Non-Secure      rwxl
    09 0x48000 0x50000      Non-Secure      rwxl
    10 0x50000 0x58000      Non-Secure      rwxl
    11 0x58000 0x60000      Non-Secure      rwxl
    12 0x60000 0x68000      Non-Secure      rwxl
    13 0x68000 0x70000      Non-Secure      rwxl
    14 0x70000 0x78000      Non-Secure      rwxl
    15 0x78000 0x80000      Non-Secure      rwxl
    16 0x80000 0x88000      Non-Secure      rwxl
    17 0x88000 0x90000      Non-Secure      rwxl
    18 0x90000 0x98000      Non-Secure      rwxl
    19 0x98000 0xa0000      Non-Secure      rwxl
    20 0xa0000 0xa8000      Non-Secure      rwxl
    21 0xa8000 0xb0000      Non-Secure      rwxl
    22 0xb0000 0xb8000      Non-Secure      rwxl
    23 0xb8000 0xc0000      Non-Secure      rwxl
    24 0xc0000 0xc8000      Non-Secure      rwxl
    25 0xc8000 0xd0000      Non-Secure      rwxl
    26 0xd0000 0xd8000      Non-Secure      rwxl
    27 0xd8000 0xe0000      Non-Secure      rwxl
    28 0xe0000 0xe8000      Non-Secure      rwxl
    29 0xe8000 0xf0000      Non-Secure      rwxl
    30 0xf0000 0xf8000      Non-Secure      rwxl
    31 0xf8000 0x100000     Non-Secure      rwxl
    Non-secure callable region 0 placed in flash region 0 with size 32.
    
    
    SRAM region             Domain          Permissions
    00 0x00000 0x02000      Secure          rwxl
    01 0x02000 0x04000      Secure          rwxl
    02 0x04000 0x06000      Secure          rwxl
    03 0x06000 0x08000      Secure          rwxl
    04 0x08000 0x0a000      Secure          rwxl
    05 0x0a000 0x0c000      Secure          rwxl
    06 0x0c000 0x0e000      Secure          rwxl
    07 0x0e000 0x10000      Secure          rwxl
    08 0x10000 0x12000      Non-Secure      rwxl
    09 0x12000 0x14000      Non-Secure      rwxl
    10 0x14000 0x16000      Non-Secure      rwxl
    11 0x16000 0x18000      Non-Secure      rwxl
    12 0x18000 0x1a000      Non-Secure      rwxl
    13 0x1a000 0x1c000      Non-Secure      rwxl
    14 0x1c000 0x1e000      Non-Secure      rwxl
    15 0x1e000 0x20000      Non-Secure      rwxl
    16 0x20000 0x22000      Non-Secure      rwxl
    17 0x22000 0x24000      Non-Secure      rwxl
    18 0x24000 0x26000      Non-Secure      rwxl
    19 0x26000 0x28000      Non-Secure      rwxl
    20 0x28000 0x2a000      Non-Secure      rwxl
    21 0x2a000 0x2c000      Non-Secure      rwxl
    22 0x2c000 0x2e000      Non-Secure      rwxl
    23 0x2e000 0x30000      Non-Secure      rwxl
    24 0x30000 0x32000      Non-Secure      rwxl
    25 0x32000 0x34000      Non-Secure      rwxl
    26 0x34000 0x36000      Non-Secure      rwxl
    27 0x36000 0x38000      Non-Secure      rwxl
    28 0x38000 0x3a000      Non-Secure      rwxl
    29 0x3a000 0x3c000      Non-Secure      rwxl
    30 0x3c000 0x3e000      Non-Secure      rwxl
    31 0x3e000 0x40000      Non-Secure      rwxl
    
    Peripheral              Domain          Status
    00 NRF_P0               Non-Secure      OK
    01 NRF_CLOCK            Non-Secure      OK
    02 NRF_RTC1             Non-Secure      OK
    03 NRF_NVMC             Non-Secure      OK
    04 NRF_UARTE1           Non-Secure      OK
    05 NRF_UARTE2           Secure          SKIP
    06 NRF_TWIM2            Non-Secure      OK
    07 NRF_SPIM3            Non-Secure      OK
    08 NRF_TIMER0           Non-Secure      OK
    09 NRF_TIMER1           Non-Secure      OK
    10 NRF_TIMER2           Non-Secure      OK
    11 NRF_SAADC            Non-Secure      OK
    12 NRF_PWM0             Non-Secure      OK
    13 NRF_PWM1             Non-Secure      OK
    14 NRF_PWM2             Non-Secure      OK
    15 NRF_PWM3             Non-Secure      OK
    16 NRF_WDT              Non-Secure      OK
    17 NRF_IPC              Non-Secure      OK
    18 NRF_VMC              Non-Secure      OK
    19 NRF_FPU              Non-Secure      OK
    20 NRF_EGU1             Non-Secure      OK
    21 NRF_EGU2             Non-Secure      OK
    22 NRF_DPPIC            Non-Secure      OK
    23 NRF_GPIOTE1          Non-Secure      OK
    24 NRF_REGULATORS       Secure          SKIP
    
    SPM: NS image at 0xc000
    SPM: NS MSP at 0x20024cf8
    SPM: NS reset vector at 0xddf9
    SPM: prepare to jump to Non-Secure image.
    *** Booting Zephyr OS build v2.0.99-ncs1-rc1-1162-g9a0a85cf6760  ***
    The MQTT simple sample started
    LTE Link Connecting ...
    +CEREG: 2,"0013","00436D0F",9,0,0,"11100000","11100000"
    +CEREG: 1,"0013","00436D0F",9,,,"11100000","11100000"
    LTE Link Connected!
    IPv6 Address 2406:da1a:275:8410:1bd5:1317:a239:9810
    [mqtt_evt_handler:194] MQTT client connected!
    Publishing: sample data
    to topic: tw/track len: 8
    Disconnecting MQTT client...
    IPv6 Address 2406:da1a:275:8410:1bd5:1317:a239:9810
    [mqtt_evt_handler:194] MQTT client connected!
    Publishing: sample data
    to topic: tw/track len: 8
    Disconnecting MQTT client...
    IPv6 Address 2406:da1a:275:8410:1bd5:1317:a239:9810
    [mqtt_evt_handler:194] MQTT client connected!
    Publishing: sample data
    to topic: tw/track len: 8
    Disconnecting MQTT client...
    IPv6 Address 2406:da1a:275:8410:1bd5:1317:a239:9810
    [mqtt_evt_handler:194] MQTT client connected!
    Publishing: sample data
    to topic: tw/track len: 8
    Disconnecting MQTT client...
    IPv6 Address 2406:da1a:275:8410:1bd5:1317:a239:9810
    [mqtt_evt_handler:194] MQTT client connected!
    Publishing: sample data
    to topic: tw/track len: 8
    Disconnecting MQTT client...
    IPv6 Address 2406:da1a:275:8410:1bd5:1317:a239:9810
    inside mqtt_connect -12ERROR: mqtt_connect -12
    IPv6 Address 2406:da1a:275:8410:1bd5:1317:a239:9810
    inside mqtt_connect -12ERROR: mqtt_connect -12

  • Thanks.

    To connect to the local network, I am using LTE-M and IPv4 instead of NB-IoT and IPv6.

    However, I still see similar results, except that I can connect 5 times before failing on the 6th.

    I'll investigate more and keep you updated.

    Best regards,

    Didrik

  • Hi.

    I have reported this problem internally and requested help from our developers.

    I'll keep you updated about any progress.

    Best regards,

    Didrik

Related