zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.9k stars 6.64k forks source link

LwM2M: Connection resume does not work after network error #54504

Closed chmielewskiandreas closed 1 year ago

chmielewskiandreas commented 1 year ago

Describe the bug

Once the RDClient is in suspended state a socket error (in my example taking the modem offline) causes that the socket is broken after the RDClient is resumed.

Steps to reproduce the behaviour. Please take the example below (just replace lwm2m_client example with this version) and execute

1) client start_network 2) client start 3) client pause 4) client stop_network 5) client start_network 6) client resume

You will see that the state machine loops within ENGINE_UPDATE_SENT until a timeout occurs. A short debugging session tracked this down to socket_fault_cb method where lwm2m_socket_close is called. This method closes the socket and because of this lwm2m_close_socket will not be called later on and connection_suspended flag will not be set to true.

Reading the code of suspending and resuming the RDClient I see a big requirement for refactoring. In particular the place/way socket is closed should be refactored e.g. lwm2m_socket_close and lwm2m_close_socket is quite irritating.

diff --git a/samples/nrf9160/lwm2m_client/prj.conf b/samples/nrf9160/lwm2m_client/prj.conf
index 7759741e9..a7b0266df 100644
--- a/samples/nrf9160/lwm2m_client/prj.conf
+++ b/samples/nrf9160/lwm2m_client/prj.conf
@@ -27,7 +27,7 @@ CONFIG_LWM2M_ENGINE_MAX_OBSERVER=15
 CONFIG_LWM2M_ENGINE_MAX_MESSAGES=15
 CONFIG_LWM2M_ENGINE_MAX_PENDING=15
 CONFIG_LWM2M_ENGINE_MAX_REPLIES=15
-CONFIG_LWM2M_ENGINE_DEFAULT_LIFETIME=30
+CONFIG_LWM2M_ENGINE_DEFAULT_LIFETIME=1200
 CONFIG_LWM2M_DNS_SUPPORT=y
 CONFIG_LWM2M_RW_JSON_SUPPORT=n
 CONFIG_LWM2M_SERVER_DEFAULT_PMIN=1
@@ -94,7 +94,7 @@ CONFIG_FOTA_DOWNLOAD=y
 CONFIG_MCUBOOT_IMAGE_VERSION="1.0.0"

 # Set LwM2M Server IP address here
-CONFIG_LWM2M_CLIENT_UTILS_SERVER="coaps://leshan.eclipseprojects.io:5684"
+CONFIG_LWM2M_CLIENT_UTILS_SERVER="coap://leshan.eclipseprojects.io:5683"

 # Application Event Manager
 CONFIG_APP_EVENT_MANAGER=y
@@ -102,3 +102,7 @@ CONFIG_APP_EVENT_MANAGER=y
 # Date-Time library
 CONFIG_DATE_TIME=y
 CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS=86400
+
+CONFIG_LWM2M_VERSION_1_1=y
+CONFIG_LWM2M_RW_SENML_CBOR_SUPPORT=y
+CONFIG_ZCBOR_CANONICAL=y
/*
 * Copyright (c) 2019 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
 */

#include <zephyr/kernel.h>
#include <ctype.h>
#include <zephyr/drivers/gpio.h>
#include <stdio.h>
#include <zephyr/net/lwm2m.h>
#include <modem/nrf_modem_lib.h>
#include <zephyr/settings/settings.h>

#include <net/lwm2m_client_utils.h>
#include <app_event_manager.h>
#include <net/lwm2m_client_utils_location.h>
#include <net/lwm2m_client_utils_location_events.h>
#include <date_time.h>

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(app_lwm2m_client, CONFIG_APP_LOG_LEVEL);

#include <modem/lte_lc.h>
#include <modem/modem_info.h>
#include <nrf_modem_at.h>
#include <lwm2m_rd_client.h>
#include "lwm2m_client_app.h"
#include "lwm2m_app_utils.h"
#include <zephyr/shell/shell.h>

#define IMEI_LEN 15
#define ENDPOINT_NAME_LEN (IMEI_LEN + sizeof(CONFIG_APP_ENDPOINT_PREFIX) + 1)

static uint8_t endpoint_name[ENDPOINT_NAME_LEN + 1];
static uint8_t imei_buf[IMEI_LEN + sizeof("\r\nOK\r\n")];

static struct lwm2m_ctx client = { 0 };

void client_acknowledge(void)
{
    lwm2m_acknowledge(&client);
}

static int lwm2m_setup(void)
{
#if defined(CONFIG_LWM2M_CLIENT_UTILS_DEVICE_OBJ_SUPPORT)
    /* Manufacturer independent */
    lwm2m_init_device();
#endif

    /* Manufacturer dependent */
    /* use IMEI as serial number */
    lwm2m_app_init_device(imei_buf);
    lwm2m_init_security(&client, endpoint_name, NULL);

    return 0;
}

static const char *lwm2m_rd_client_event_to_str(enum lwm2m_rd_client_event client_event)
{
    switch (client_event) {
    case LWM2M_RD_CLIENT_EVENT_REGISTRATION_FAILURE:
        return "Registration failure!";
    case LWM2M_RD_CLIENT_EVENT_REG_TIMEOUT:
        return "Registration update failure!";
    case LWM2M_RD_CLIENT_EVENT_DISCONNECT:
        return "Disconnected";
    case LWM2M_RD_CLIENT_EVENT_REGISTRATION_COMPLETE:
        return "Registration complete";
    case LWM2M_RD_CLIENT_EVENT_REG_UPDATE_COMPLETE:
        return "Registration update complete";
    case LWM2M_RD_CLIENT_EVENT_NETWORK_ERROR:
        return "LwM2M engine reported a network error!";
    case LWM2M_RD_CLIENT_EVENT_BOOTSTRAP_REG_FAILURE:
        return "Bootstrap registration failure!";
    case LWM2M_RD_CLIENT_EVENT_BOOTSTRAP_REG_COMPLETE:
        return "Bootstrap registration complete";
    case LWM2M_RD_CLIENT_EVENT_BOOTSTRAP_TRANSFER_COMPLETE:
        return "Bootstrap transfer complete";
    case LWM2M_RD_CLIENT_EVENT_DEREGISTER_FAILURE:
        return "Deregister failure!";
    case LWM2M_RD_CLIENT_EVENT_QUEUE_MODE_RX_OFF:
        return "Queue mode RX window closed";
    case LWM2M_RD_CLIENT_EVENT_ENGINE_SUSPENDED:
        return "LwM2M engine suspended";
    case LWM2M_RD_CLIENT_EVENT_NONE:
        return "No event";
    }
    return "Unknown event from RDClient";
}

static const char *lte_lc_nw_reg_status_to_str(enum lte_lc_nw_reg_status nw_reg_status)
{
    switch (nw_reg_status) {
    case LTE_LC_NW_REG_REGISTERED_HOME:
        return "Connected - home network";
    case LTE_LC_NW_REG_REGISTERED_ROAMING:
        return "Connected - roaming";
    case LTE_LC_NW_REG_SEARCHING:
        return "Searching for network";
    case LTE_LC_NW_REG_NOT_REGISTERED:
        return "Not registered";
    case LTE_LC_NW_REG_REGISTRATION_DENIED:
        return "Registration denied";
    case LTE_LC_NW_REG_UNKNOWN:
        return "Registration unknown";
    case LTE_LC_NW_REG_REGISTERED_EMERGENCY:
        return "Registered emergency";
    case LTE_LC_NW_REG_UICC_FAIL:
        return "No SIM card detected";
    }
    return "Unknown registration status";
}

static void lwm2m_event_cb(struct lwm2m_ctx *client, enum lwm2m_rd_client_event client_event)
{
    ARG_UNUSED(client);

    LOG_DBG("LwM2M event - %s", lwm2m_rd_client_event_to_str(client_event));
}

static void handle_reg_status(enum lte_lc_nw_reg_status nw_reg_status)
{
    LOG_DBG("LTE Registration Status - %s", lte_lc_nw_reg_status_to_str(nw_reg_status));
}

void lte_event_cb(const struct lte_lc_evt *evt)
{
    switch (evt->type) {
    case LTE_LC_EVT_NW_REG_STATUS:
        handle_reg_status(evt->nw_reg_status);
        break;
    default:
        break;
    }
}

static const char *send_paths[] = { "3/0/3", "3/0/13" };

static void lwm2m_send_periodically_fn(struct k_work *work);
K_WORK_DELAYABLE_DEFINE(lwm2m_send_periodically, lwm2m_send_periodically_fn);

static void lwm2m_send_periodically_fn(struct k_work *work)
{
    ARG_UNUSED(work);

    int err = lwm2m_send_cb(&client, send_paths, ARRAY_SIZE(send_paths), NULL);
    if (err) {
        LOG_ERR("Failed to perform lwm2m_send: %d", err);
    }
    k_work_schedule(&lwm2m_send_periodically, K_SECONDS(10));
}

void main(void)
{
    int ret;

    LOG_INF("Initializing modem.");
    ret = nrf_modem_lib_init(NORMAL_MODE);
    if (ret < 0) {
        LOG_ERR("Unable to init modem library (%d)", ret);
        return;
    }

    ret = lte_lc_init();
    if (ret < 0) {
        LOG_ERR("Unable to init modem (%d)", ret);
        return;
    }

    ret = modem_info_init();
    if (ret < 0) {
        LOG_ERR("Unable to init modem_info (%d)", ret);
        return;
    }

    /* query IMEI */
    ret = modem_info_string_get(MODEM_INFO_IMEI, imei_buf, sizeof(imei_buf));
    if (ret < 0) {
        LOG_ERR("Unable to get IMEI");
        return;
    }

    /* use IMEI as unique endpoint name */
    snprintk(endpoint_name, sizeof(endpoint_name), "%s%s", CONFIG_APP_ENDPOINT_PREFIX,
         imei_buf);
    LOG_INF("endpoint: %s", (char *)endpoint_name);

    /* Setup LwM2M */
    ret = lwm2m_setup();
    if (ret < 0) {
        LOG_ERR("Failed to setup LWM2M fields (%d)", ret);
        return;
    }

    k_work_schedule(&lwm2m_send_periodically, K_SECONDS(10));
}

static int start_network_debug_cmd(const struct shell *shell, size_t argc, char **argv)
{
    ARG_UNUSED(shell);
    ARG_UNUSED(argc);
    ARG_UNUSED(argv);

    int err = lte_lc_connect_async(lte_event_cb);
    if (err) {
        LOG_ERR("lte_lc_connect_async failed: %d", err);
    }

    return 0;
}

static int stop_network_debug_cmd(const struct shell *shell, size_t argc, char **argv)
{
    ARG_UNUSED(shell);
    ARG_UNUSED(argc);
    ARG_UNUSED(argv);

    int err = lte_lc_offline();
    if (err) {
        LOG_ERR("lte_lc_offline failed: %d", err);
    }

    return 0;
}

static int start_client_debug_cmd(const struct shell *shell, size_t argc, char **argv)
{
    ARG_UNUSED(shell);
    ARG_UNUSED(argc);
    ARG_UNUSED(argv);

    lwm2m_rd_client_start(&client, endpoint_name, 0, lwm2m_event_cb, NULL);

    return 0;
}

static int pause_client_debug_cmd(const struct shell *shell, size_t argc, char **argv)
{
    ARG_UNUSED(shell);
    ARG_UNUSED(argc);
    ARG_UNUSED(argv);

    int err = lwm2m_rd_client_pause();
    if (err) {
        LOG_ERR("lwm2m_rd_client_pause failed: %d", err);
    }

    return 0;
}

static int resume_client_debug_cmd(const struct shell *shell, size_t argc, char **argv)
{
    ARG_UNUSED(shell);
    ARG_UNUSED(argc);
    ARG_UNUSED(argv);

    int err = lwm2m_rd_client_resume();
    if (err) {
        LOG_ERR("lwm2m_rd_client_resume failed: %d", err);
    }

    return 0;
}

SHELL_STATIC_SUBCMD_SET_CREATE(
    shell_client,
    SHELL_CMD_ARG(start_network, NULL, "Start Network debug", start_network_debug_cmd, 1, 1),
    SHELL_CMD_ARG(stop_network, NULL, "Stop Network debug", stop_network_debug_cmd, 1, 1),
    SHELL_CMD_ARG(start, NULL, "Start client debug", start_client_debug_cmd, 1, 1),
    SHELL_CMD_ARG(pause, NULL, "Pause client debug", pause_client_debug_cmd, 1, 1),
    SHELL_CMD_ARG(resume, NULL, "Resume client debug", resume_client_debug_cmd, 1, 1),
    SHELL_SUBCMD_SET_END);

SHELL_CMD_REGISTER(client, &shell_client, "Client commands", NULL);
uart:~$ client start_network
[00:00:17.879,486] <dbg> app_lwm2m_client: handle_reg_status: LTE Registration Status - Searching for network
[00:00:17.879,516] <dbg> app_lwm2m_client: handle_cell_update: Old cell id: 0x00000000
[00:00:17.879,547] <wrn> app_lwm2m_client: New cell id: 0x009fc903
[00:00:17.879,547] <dbg> app_lwm2m_client: handle_cell_update: Old tracking area code: 0x0000
[00:00:17.879,577] <wrn> app_lwm2m_client: New tracking area code: 0xad73
[00:00:17.879,669] <dbg> app_lwm2m_client: lte_event_cb: Active LTE mode changed: LTE-M
[00:00:18.041,625] <dbg> app_lwm2m_client: lte_event_cb: RCC mode: Connected
uart:~$ client start
[00:00:20.029,602] <inf> net_lwm2m_rd_client: ******* new state is ENGINE_INIT
[00:00:20.029,663] <inf> net_lwm2m_rd_client: Start LWM2M Client: urn:imei:352656106103065
[00:00:20.265,625] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_INIT
[00:00:20.265,686] <err> net_lwm2m_engine: >>>>>>>>>>>>> lwm2m_socket_close
[00:00:20.265,747] <inf> net_lwm2m_rd_client: ******* new state is ENGINE_DO_REGISTRATION
[00:00:20.510,894] <err> app_lwm2m_client: failed to perform lwm2m_send: -1
[00:00:20.738,586] <dbg> app_lwm2m_client: handle_reg_status: LTE Registration Status - Connected - roaming
[00:00:20.739,654] <dbg> app_lwm2m_client: lte_event_cb: PSM update: TAU: 3240, Active time: -1
[00:00:20.765,899] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_DO_REGISTRATION
[00:00:20.766,113] <inf> net_lwm2m_rd_client: RD Client started with endpoint 'urn:imei:352656106103065' with client lifetime 1200
[00:00:21.167,999] <inf> net_lwm2m_engine: Connected, sock id 0
[00:00:21.169,555] <dbg> net_lwm2m_rd_client: sm_send_registration: registration sent [23.97.187.154]
[00:00:21.169,586] <inf> net_lwm2m_rd_client: ******* new state is ENGINE_REGISTRATION_SENT
[00:00:21.266,021] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_REGISTRATION_SENT
[00:00:21.386,108] <dbg> net_lwm2m_rd_client: do_registration_reply_cb: Registration callback (code:2.1)
[00:00:21.386,169] <inf> net_lwm2m_rd_client: ******* new state is ENGINE_REGISTRATION_DONE
[00:00:21.386,199] <dbg> app_lwm2m_client: lwm2m_event_cb: LwM2M event - Registration complete
[00:00:21.386,260] <inf> net_lwm2m_rd_client: Registration Done (EP='Cf9YTAxOHq')
[00:00:21.765,716] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_REGISTRATION_DONE
[00:00:22.265,960] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_REGISTRATION_DONE
[00:00:22.766,204] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_REGISTRATION_DONE
[00:00:23.266,448] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_REGISTRATION_DONE
[00:00:23.766,693] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_REGISTRATION_DONE
[00:00:24.266,937] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_REGISTRATION_DONE
[00:00:24.767,181] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_REGISTRATION_DONE
[00:00:25.267,425] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_REGISTRATION_DONE
[00:00:25.767,669] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_REGISTRATION_DONE
[00:00:26.267,913] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_REGISTRATION_DONE
uart:~$ client pause
[00:00:26.768,188] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_REGISTRATION_DONE
[00:00:27.268,432] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_REGISTRATION_DONE
[00:00:27.378,997] <inf> net_lwm2m_rd_client: Suspend client
[00:00:27.379,028] <dbg> app_lwm2m_client: lwm2m_event_cb: LwM2M event - LwM2M engine suspended
[00:00:27.379,058] <inf> net_lwm2m_rd_client: ******** after lwm2m_rd_client_pause 0
[00:00:27.768,707] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:28.268,920] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:28.769,165] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:29.269,378] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:29.769,622] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
uart:~$ client stop_network
[00:00:30.270,080] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:30.770,324] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:30.922,485] <inf> net_lwm2m_message_handling: Send done!
[00:00:31.270,294] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:31.669,128] <err> net_lwm2m_engine: Poll reported a socket error, 08.
[00:00:31.669,189] <err> net_lwm2m_rd_client: RD Client socket error: 5
[00:00:31.669,189] <err> net_lwm2m_engine: >>>>>>>>>>>>> lwm2m_socket_close
[00:00:31.669,921] <dbg> app_lwm2m_client: handle_reg_status: LTE Registration Status - Not registered
[00:00:31.669,952] <dbg> app_lwm2m_client: handle_cell_update: Old cell id: 0x009fc903
[00:00:31.669,982] <wrn> app_lwm2m_client: New cell id: 0xffffffff
[00:00:31.669,982] <dbg> app_lwm2m_client: handle_cell_update: Old tracking area code: 0xad73
[00:00:31.670,013] <wrn> app_lwm2m_client: New tracking area code: 0xffffffff
[00:00:31.670,074] <dbg> app_lwm2m_client: lte_event_cb: Active LTE mode changed: None
[00:00:31.770,599] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:32.270,751] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:32.770,935] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:33.036,529] <dbg> app_lwm2m_client: lte_event_cb: RCC mode: Idle
[00:00:33.271,118] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:33.771,270] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:34.271,453] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:34.771,606] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:35.271,759] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:35.771,911] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:36.272,064] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
uart:~$ client start_network
[00:00:36.772,216] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:37.272,369] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:37.772,521] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:38.206,024] <dbg> app_lwm2m_client: handle_reg_status: LTE Registration Status - Searching for network
[00:00:38.206,054] <dbg> app_lwm2m_client: handle_cell_update: Old cell id: 0xffffffff
[00:00:38.206,085] <wrn> app_lwm2m_client: New cell id: 0x00a73d01
[00:00:38.206,085] <dbg> app_lwm2m_client: handle_cell_update: Old tracking area code: 0xffffffff
[00:00:38.206,115] <wrn> app_lwm2m_client: New tracking area code: 0xad73
[00:00:38.206,176] <dbg> app_lwm2m_client: lte_event_cb: Active LTE mode changed: LTE-M
[00:00:38.272,705] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:38.533,081] <dbg> app_lwm2m_client: lte_event_cb: RCC mode: Connected
[00:00:38.772,857] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:39.273,010] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:39.649,963] <dbg> app_lwm2m_client: handle_reg_status: LTE Registration Status - Connected - roaming
[00:00:39.773,193] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:40.273,468] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:40.773,620] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
uart:~$ client resume
[00:00:41.273,773] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_SUSPENDED
[00:00:41.431,884] <inf> net_lwm2m_rd_client: Resume Client state
[00:00:41.431,915] <inf> net_lwm2m_rd_client: ******** 1 lwm2m_rd_client_resume 0
[00:00:41.431,915] <inf> net_lwm2m_rd_client: ******** 2 lwm2m_rd_client_resume 0
[00:00:41.773,925] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_REGISTRATION_DONE
[00:00:41.773,956] <inf> net_lwm2m_rd_client: ******* new state is ENGINE_UPDATE_REGISTRATION
[00:00:41.774,566] <err> net_lwm2m_message_handling: Failed to send packet, err 121
[00:00:42.273,895] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_UPDATE_REGISTRATION
[00:00:42.273,895] <inf> net_lwm2m_rd_client: ***** update registration
[00:00:42.273,925] <err> net_lwm2m_engine: *******>>>>> lwm2m_engine_connection_resume 0
[00:00:42.274,627] <dbg> net_lwm2m_rd_client: sm_send_registration: registration sent [23.97.187.154]
[00:00:42.274,658] <inf> net_lwm2m_rd_client: ******* new state is ENGINE_UPDATE_SENT
[00:00:42.275,268] <err> net_lwm2m_message_handling: Failed to send packet, err 121
[00:00:42.773,498] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_UPDATE_SENT
[00:00:43.273,742] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_UPDATE_SENT
[00:00:43.773,956] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_UPDATE_SENT
[00:00:44.274,200] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_UPDATE_SENT
[00:00:44.774,414] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_UPDATE_SENT
[00:00:45.274,658] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_UPDATE_SENT
[00:00:45.774,871] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_UPDATE_SENT
[00:00:45.858,154] <err> net_lwm2m_message_handling: Failed to send packet, err 121
[00:00:46.274,414] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_UPDATE_SENT
[00:00:46.774,658] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_UPDATE_SENT
[00:00:47.274,871] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_UPDATE_SENT
[00:00:47.775,115] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_UPDATE_SENT
[00:00:48.174,102] <err> net_lwm2m_message_handling: Failed to send packet, err 121
[00:00:48.275,329] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_UPDATE_SENT
[00:00:48.775,573] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_UPDATE_SENT
[00:00:49.275,787] <inf> net_lwm2m_rd_client: ******* current state is ENGINE_UPDATE_SENT
SeppoTakalo commented 1 year ago

The log message look like this is either quite old, or modified client.

I cannot anymore replicate the exact issue, but I found couple that could be causing this behaviour. Please see #55030 If you still have the set up, can you try out if this fixes the exact issue that you are facing.

chmielewskiandreas commented 1 year ago

Thanks @SeppoTakalo. This solved the issue.