CLEAN_SESSION Not work

I have problems when I connect to my mqtt broker, it looks like it doesn't do a CLEAN_SESSION.. according to server logs.. I see when I connect to test clients ( pc ) with CLEAN_SESSION then it clearly appears in the log. This creates a lot of problems e.g. the client id is not registered by mqtt broker.. etc..


conntions from nrf7002 is not clean=1 and not completed normally

Here log from my 7002 

connection.log:2025-02-23T05:52:07.044Z Connection tcpiop.1 CWLNA1117 I: Create mqtt connection: ConnectionID=599 ClientID="_85.166.49.173_dS9ZdNyj" Endpoint="mqtt-ssl-ldap" UserID="demo24" CommonName="" Durable=0.

connection.log:2025-02-23T05:52:07.247Z Connection tcpiop.1 CWLNA2202 W: A message consumer could not be created due to an authorization failure: ConnectionID=599 ClientID="_85.166.49.173_dS9ZdNyj" Protocol="mqtt4-tcp" Endpoint="mqtt-ssl-ldap" UserID="demo24".


this log from working test client ( pc mosquitto ) 

-connection.log:2025-02-23T20:12:14.118Z Connection tcpiop.1 CWLNA1117 I: Create mqtt connection: ConnectionID=3199 ClientID="41675380" Endpoint="mqtt-ssl-ldap" UserID="rb3" CommonName="" Durable=0.
-connection.log:2025-02-23T20:12:14.164Z Connection tcpiop.1 CWLNA1111 N: Closing TCP connection: ConnectionID=3199 MonitorID=3199 ClientID="41675380" Protocol=mqtt4-tcp Endpoint="mqtt-ssl-ldap" From=[85.166.49.173]:59917 UserID="rb3" Uptime=0 RC=0 Clean=1 Reason="The connection has completed normally." ReadBytes=818 ReadMsg=1 WriteBytes=2,141 WriteMsg=0 LostMsg=0 WarnMsg=0.

# MQTT
CONFIG_MQTT_LIB=y
CONFIG_MQTT_CLEAN_SESSION=y
CONFIG_MQTT_LOG_LEVEL_DBG=y

Is this a known problem? Is there any way to get a receipt that it is sending with a clean session? Does anyone have any suggestions?

Parents
  • Hi,

    This is concerning, and indicate a problem with your certificate(s): 

    W: A message consumer could not be created due to an authorization failure:

    Can you share logs from the nRF-side? Does your device connect to the broker at all?

     

    Kind regards,

    Håkon

  • hey, forgot to say something the error messages come from the broker because of a topic policy (i think)?

    AND all messages are delivered and work fine.  only Client id is problem/Clan sessoin. part. 

    Here excerpt from the communication between us and mqtt melger support:

    i ask supprt:
    Could the policy error message have something to do with it not recognizing the client ID? Before I send the clan session.

    Admin say: No. It has already determined the clientid before it starts to try and consume things

    but you said that i can see in the NRF log i haven't done that. can i see MQTT logs there? or do i have to turn it on in the configrue is it default there?

    list of Clients all client with IP-ADDRESS IS nRF devifes. 

Reply
  • hey, forgot to say something the error messages come from the broker because of a topic policy (i think)?

    AND all messages are delivered and work fine.  only Client id is problem/Clan sessoin. part. 

    Here excerpt from the communication between us and mqtt melger support:

    i ask supprt:
    Could the policy error message have something to do with it not recognizing the client ID? Before I send the clan session.

    Admin say: No. It has already determined the clientid before it starts to try and consume things

    but you said that i can see in the NRF log i haven't done that. can i see MQTT logs there? or do i have to turn it on in the configrue is it default there?

    list of Clients all client with IP-ADDRESS IS nRF devifes. 

Children
  • Hi,

     

    I have set the config in question, and connected to a local mosquitto server, which has verbose logging enabled.

    What is logged in the mosquitto.log file is:

    ...
    New client connected from 192.168.32.209:43333 as nrf7002dk-4172493585 (p2, c1, k60)
    ...
     

    And this is the exact fields logged here:

    https://github.com/eclipse-mosquitto/mosquitto/blob/master/src/handle_connect.c#L235-L236

     

    You can also go into debug mode and check that the field is indeed set on your side when calling mqtt_client_init():

    https://github.com/nrfconnect/sdk-zephyr/blob/v3.7.99-ncs2/subsys/net/lib/mqtt/mqtt.c#L180

     

    Can you please share information on how your client side implementation is setup?

    Dev-ercom said:

    i ask supprt:
    Could the policy error message have something to do with it not recognizing the client ID? Before I send the clan session.

    Admin say: No. It has already determined the clientid before it starts to try and consume things

    but you said that i can see in the NRF log i haven't done that. can i see MQTT logs there? or do i have to turn it on in the configrue is it default there?

    Logs can be enabled by setting CONFIG_SERIAL=y and CONFIG_LOG=y and opening up the COM-port using your favorite terminal (putty, realterm, etc).

    Which example are you using, and what ncs version are you using?

     

    Kind regards,

    Håkon

  • Helloi .i made debug mode like you say in putty: 

    I don't understand much more but maybe the log will tell you something?

    =~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2025.03.04 14:15:00 =~=~=~=~=~=~=~=~=~=~=~=
    ÿI: device id is c2 28 14

    I: mx25r6435f@0: 1 MiBy flash
    *** Booting Zephyr OS build v3.2.99-ncs2 ***
    I: Starting bootloader
    I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Boot source: none
    I: Swap type: none
    I: Bootloader chainload address offset: 0x10000
    I: Jumping to the first image slot [00:00:00.001,007] [0m<inf> spi_nor: spi_nor_configure: device id is c2 28 14
    [0m
    [00:00:00.001,007] [0m<inf> spi_nor: spi_nor_process_bfp: mx25r6435f@0: 1 MiBy flash[0m
    [00:00:00.021,575] [0m<inf> wifi_nrf: qspi_init: QSPI freq = 24 MHz
    [0m
    [00:00:00.021,606] [0m<inf> wifi_nrf: qspi_init: QSPI latency = 1
    [0m
    [00:00:00.029,113] [0m<inf> wifi_nrf: zep_shim_pr_info: wifi_nrf_fmac_fw_load: LMAC patches loaded
    [0m
    [00:00:00.039,947] [0m<inf> wifi_nrf: zep_shim_pr_info: wifi_nrf_fmac_fw_load: LMAC boot check passed
    [0m
    [00:00:00.042,907] [0m<inf> wifi_nrf: zep_shim_pr_info: wifi_nrf_fmac_fw_load: UMAC patches loaded
    [0m
    [00:00:00.053,710] [0m<inf> wifi_nrf: zep_shim_pr_info: wifi_nrf_fmac_fw_load: UMAC boot check passed
    [0m
    [00:00:00.075,714] [0m<inf> wifi_nrf: zep_shim_pr_info: RPU LPM type: HW
    [0m
    [00:00:00.190,216] [0m<dbg> net_dns_resolve: dns_resolve_init_locked: (0x20008430): [0] 8.8.8.8[0m
    [00:00:00.194,091] [0m<inf> fs_nvs: nvs_mount: 2 Sectors of 4096 bytes[0m
    [00:00:00.194,122] [0m<inf> fs_nvs: nvs_mount: alloc wra: 0, fd0[0m
    [00:00:00.194,122] [0m<inf> fs_nvs: nvs_mount: data wra: 0, 161[0m
    *** Booting Zephyr OS build v3.2.99-ncs2 ***
    [00:00:00.194,763] [0m<inf> wpa_supp: wpa_printf_impl: z_wpas_start: 385 Starting wpa_supplicant thread with debug level: 3
    [0m
    [00:00:00.195,007] [0m<inf> wpa_supp: wpa_printf_impl: Successfully initialized wpa_supplicant[0m
    [00:00:00.195,861] [0m<inf> MQTT_MAIN: ADC_entry_point: ADC init ok
    [0m
    [00:00:02.194,702] [0m<inf> MQTT_WIFIUTILS: WifiInitToWifi: MAC ADDR: F6:EC:28:00:44:0E
    [0m
    [00:00:02.194,732] [0m<inf> MQTT_WIFIUTILS: WifiConnectAP: ********************************
    [0m
    [00:00:02.194,824] [0m<inf> MQTT_WIFIUTILS: WifiConnectAP: ***************wifi_credentials_for_each_ssid*****************
    [0m
    [00:00:02.194,824] [0m<inf> MQTT_WIFIUTILS: WifiConnectAP: Configuration found. Try to apply!!!!.
    [0m
    [00:00:02.194,854] [0m<inf> MQTT_WIFIUTILS: WifiConnectAP: ssid: myoplink[0m
    [00:00:02.217,895] [0m<inf> MQTT_WIFIUTILS: WifiConnectAP: Configuration applied.
    [0m
    [00:00:02.217,926] [0m<inf> MQTT_WIFIUTILS: WifiTask: wifi send connect ok[0m
    [00:00:06.559,967] [0m<inf> wpa_supp: wpa_printf_impl: wlan0: SME: Trying to authenticate with f6:90:55:84:c5:41 (SSID='myoplink' freq=2437 MHz)[0m
    [00:00:06.563,385] [0m<inf> wifi_nrf: wifi_nrf_wpa_supp_authenticate: wifi_nrf_wpa_supp_authenticate:Authentication request sent successfully
    [0m
    [00:00:07.022,521] [0m<inf> wpa_supp: wpa_printf_impl: wlan0: Trying to associate with f6:90:55:84:c5:41 (SSID='myoplink' freq=2437 MHz)[0m
    [00:00:07.029,876] [0m<inf> wifi_nrf: wifi_nrf_wpa_supp_associate: wifi_nrf_wpa_supp_associate: Association request sent successfully
    [0m
    [00:00:07.069,732] [0m<inf> wpa_supp: wpa_printf_impl: wlan0: Associated with f6:90:55:84:c5:41[0m
    [00:00:07.069,976] [0m<inf> wpa_supp: wpa_printf_impl: wlan0: CTRL-EVENT-CONNECTED - Connection to f6:90:55:84:c5:41 completed [id=0 id_str=][0m
    [00:00:07.077,606] [0m<inf> MQTT_WIFIUTILS: wifi_event_handler: Connected to a Wi-Fi Network[0m
    [00:00:07.077,728] [0m<inf> wpa_supp: wpa_printf_impl: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0[0m
    [00:00:07.261,901] [0m<dbg> net_dns_resolve: dns_resolve_reconfigure: (0x20007f10): this is the entry point[0m
    [00:00:07.276,000] [0m<dbg> net_dns_resolve: dns_resolve_reconfigure: (0x20007f10): this is the entry point[0m
    [00:00:07.276,123] [0m<inf> net_dhcpv4: dhcpv4_handle_msg_ack: Received: 192.168.32.92[0m
    [00:00:14.220,031] [0m<inf> net_mqtt: mqtt_client_init: clean_session is 1[0m
    [00:00:14.220,214] [0m<dbg> net_dns_resolve: dns_resolve_name: (0x20008430): DNS id will be 5198[0m
    [00:00:14.220,275] [0m<dbg> net_dns_resolve: dns_write: (0x20008430): [0] submitting work to server idx 0 for id 5198 hash 12986[0m
    [00:00:14.577,087] [0m<inf> MQTT_CONNECTION: broker_init: IPv4 Address for broker found 149.81.72.149[0m
    [00:00:14.577,117] [0m<dbg> MQTT_CONNECTION: client_id_get: client_id = 8780ef[0m
    [00:00:14.577,148] [0m<inf> MQTT_CONNECTION: MqttTask: ***************MQTT INIT OK*****************
    [0m
    [00:00:24.777,282] [0m<inf> MQTT_CONNECTION: MqttTask: mqtt connectting...[0m
    [00:00:24.777,404] [0m<dbg> net_mqtt_sock_tls: mqtt_client_tls_connect: (0x20008430): Created socket 7[0m
    [00:00:26.148,406] [0m<dbg> net_mqtt_sock_tls: mqtt_client_tls_connect: (0x20008430): Connect completed[0m
    [00:00:26.148,468] [0m<dbg> net_mqtt_enc: connect_request_encode: Encoding Protocol Description.
    4d 51 54 54 |MQTT [0m
    [00:00:26.148,498] [0m<dbg> net_mqtt_enc: pack_utf8_str: (0x20008430): >> str_size:00000006 cur:0x2000bfad, end:0x2000c028[0m
    [00:00:26.148,529] [0m<dbg> net_mqtt_enc: pack_uint16: (0x20008430): >> val:0004 cur:0x2000bfad, end:0x2000c028[0m
    [00:00:26.148,559] [0m<dbg> net_mqtt_enc: connect_request_encode: (0x20008430): Encoding Protocol Version 04.[0m
    [00:00:26.148,590] [0m<dbg> net_mqtt_enc: pack_uint8: (0x20008430): >> val:04 cur:0x2000bfb3, end:0x2000c028[0m
    [00:00:26.148,651] [0m<dbg> net_mqtt_enc: pack_uint8: (0x20008430): >> val:00 cur:0x2000bfb4, end:0x2000c028[0m
    [00:00:26.148,651] [0m<dbg> net_mqtt_enc: connect_request_encode: (0x20008430): Encoding Keep Alive Time 003c.[0m
    [00:00:26.148,681] [0m<dbg> net_mqtt_enc: pack_uint16: (0x20008430): >> val:003c cur:0x2000bfb5, end:0x2000c028[0m
    [00:00:26.148,712] [0m<dbg> net_mqtt_enc: connect_request_encode: Encoding Client Id.
    38 37 38 30 65 66 |8780ef [0m
    [00:00:26.148,742] [0m<dbg> net_mqtt_enc: pack_utf8_str: (0x20008430): >> str_size:00000008 cur:0x2000bfb7, end:0x2000c028[0m
    [00:00:26.148,803] [0m<dbg> net_mqtt_enc: pack_uint16: (0x20008430): >> val:0006 cur:0x2000bfb7, end:0x2000c028[0m
    [00:00:26.148,834] [0m<dbg> net_mqtt_enc: connect_request_encode: Encoding Username.
    72 62 31 |rb1 [0m
    [00:00:26.148,864] [0m<dbg> net_mqtt_enc: pack_utf8_str: (0x20008430): >> str_size:00000005 cur:0x2000bfbf, end:0x2000c028[0m
    [00:00:26.148,895] [0m<dbg> net_mqtt_enc: pack_uint16: (0x20008430): >> val:0003 cur:0x2000bfbf, end:0x2000c028[0m
    [00:00:26.148,925] [0m<dbg> net_mqtt_enc: connect_request_encode: Encoding Password.
    77 32 6b 6f 65 65 61 73 |xxxxxxxx [0m
    [00:00:26.148,986] [0m<dbg> net_mqtt_enc: pack_utf8_str: (0x20008430): >> str_size:0000000a cur:0x2000bfc4, end:0x2000c028[0m
    [00:00:26.149,017] [0m<dbg> net_mqtt_enc: pack_uint16: (0x20008430): >> val:0008 cur:0x2000bfc4, end:0x2000c028[0m
    [00:00:26.149,017] [0m<dbg> net_mqtt_enc: mqtt_encode_fixed_header: (0x20008430): << msg type:0x10 length:0x00000021[0m
    [00:00:26.149,078] [0m<dbg> net_mqtt_enc: packet_length_encode: (0x20008430): >> length:0x00000021 cur:(nil), end:(nil)[0m
    [00:00:26.149,078] [0m<dbg> net_mqtt_enc: mqtt_encode_fixed_header: (0x20008430): Fixed header length = 02[0m
    [00:00:26.149,108] [0m<dbg> net_mqtt_enc: pack_uint8: (0x20008430): >> val:10 cur:0x2000bfab, end:0x2000c028[0m
    [00:00:26.149,169] [0m<dbg> net_mqtt_enc: packet_length_encode: (0x20008430): >> length:0x00000021 cur:0x2000bfac, end:0x2000c028[0m
    [00:00:26.149,841] [0m<inf> net_mqtt: client_connect: Connect completed[0m
    [00:00:26.149,841] [0m<inf> MQTT_CONNECTION: MqttTask: ***************MQTT CONNECT OK*****************
    [0m
    [00:00:26.475,677] [0m<dbg> net_mqtt: mqtt_input: (0x20008430): state:0x00000002[0m
    [00:00:26.475,738] [0m<dbg> net_mqtt_dec: unpack_uint8: (0x20008430): >> cur:0x2000c028, end:0x2000c02a[0m
    [00:00:26.475,738] [0m<dbg> net_mqtt_dec: unpack_uint8: (0x20008430): << val:20[0m
    [00:00:26.475,769] [0m<dbg> net_mqtt_dec: packet_length_decode: (0x20008430): length:0x00000002[0m
    [00:00:26.475,769] [0m<dbg> net_mqtt_rx: mqtt_handle_packet: (0x20008430): [CID 0x200085d8]: Received MQTT_PKT_TYPE_CONNACK![0m
    [00:00:26.475,799] [0m<dbg> net_mqtt_dec: unpack_uint8: (0x20008430): >> cur:0x2000c02a, end:0x2000c02c[0m
    [00:00:26.475,830] [0m<dbg> net_mqtt_dec: unpack_uint8: (0x20008430): << val:00[0m
    [00:00:26.475,860] [0m<dbg> net_mqtt_dec: unpack_uint8: (0x20008430): >> cur:0x2000c02b, end:0x2000c02c[0m
    [00:00:26.475,860] [0m<dbg> net_mqtt_dec: unpack_uint8: (0x20008430): << val:00[0m
    [00:00:26.475,891] [0m<dbg> net_mqtt_dec: connect_ack_decode: (0x20008430): [CID 0x200085d8]: session_present_flag: 0[0m
    [00:00:26.475,891] [0m<dbg> net_mqtt_rx: mqtt_handle_packet: (0x20008430): [CID 0x200085d8]: return_code: 0[0m
    [00:00:26.475,921] [0m<inf> MQTT_CONNECTION: mqtt_evt_handler: MQTT client connected[0m
    [00:00:26.475,952] [0m<inf> MQTT_CONNECTION: subscribe: Subscribing to: iotdm-1/device/update len 21[0m
    [00:00:26.475,952] [0m<dbg> net_mqtt: mqtt_subscribe: (0x20008430): [CID 0x200085d8]:[State 0x06]: >> message id 0x04d2 topic count 0x0001[0m
    [00:00:26.476,013] [0m<dbg> net_mqtt_enc: pack_uint16: (0x20008430): >> val:04d2 cur:0x2000bfad, end:0x2000c028[0m
    [00:00:26.476,043] [0m<dbg> net_mqtt_enc: pack_utf8_str: (0x20008430): >> str_size:00000017 cur:0x2000bfaf, end:0x2000c028[0m
    [00:00:26.476,074] [0m<dbg> net_mqtt_enc: pack_uint16: (0x20008430): >> val:0015 cur:0x2000bfaf, end:0x2000c028[0m
    [00:00:26.476,135] [0m<dbg> net_mqtt_enc: pack_uint8: (0x20008430): >> val:01 cur:0x2000bfc6, end:0x2000c028[0m
    [00:00:26.476,135] [0m<dbg> net_mqtt_enc: mqtt_encode_fixed_header: (0x20008430): << msg type:0x82 length:0x0000001a[0m
    [00:00:26.476,196] [0m<dbg> net_mqtt_enc: packet_length_encode: (0x20008430): >> length:0x0000001a cur:(nil), end:(nil)[0m
    [00:00:26.476,196] [0m<dbg> net_mqtt_enc: mqtt_encode_fixed_header: (0x20008430): Fixed header length = 02[0m
    [00:00:26.476,226] [0m<dbg> net_mqtt_enc: pack_uint8: (0x20008430): >> val:82 cur:0x2000bfab, end:0x2000c028[0m
    [00:00:26.476,287] [0m<dbg> net_mqtt_enc: packet_length_encode: (0x20008430): >> length:0x0000001a cur:0x2000bfac, end:0x2000c028[0m
    [00:00:26.476,287] [0m<dbg> net_mqtt: client_write: (0x20008430): [0x200085d8]: Transport writing 28 bytes.[0m
    [00:00:26.476,898] [0m<dbg> net_mqtt: client_write: (0x20008430): [0x200085d8]: Transport write complete.[0m
    [00:00:26.476,928] [0m<dbg> net_mqtt: mqtt_subscribe: (0x20008430): [CID 0x200085d8]:[State 0x06]: << result 0x00000000[0m
    [00:00:26.816,833] [0m<dbg> net_mqtt: mqtt_input: (0x20008430): state:0x00000006[0m
    [00:00:26.816,894] [0m<dbg> net_mqtt_dec: unpack_uint8: (0x20008430): >> cur:0x2000c028, end:0x2000c02a[0m
    [00:00:26.816,925] [0m<dbg> net_mqtt_dec: unpack_uint8: (0x20008430): << val:90[0m
    [00:00:26.816,925] [0m<dbg> net_mqtt_dec: packet_length_decode: (0x20008430): length:0x00000003[0m
    [00:00:26.816,955] [0m<dbg> net_mqtt_rx: mqtt_handle_packet: (0x20008430): [CID 0x200085d8]: Received MQTT_PKT_TYPE_SUBACK![0m
    [00:00:26.816,986] [0m<dbg> net_mqtt_dec: unpack_uint16: (0x20008430): >> cur:0x2000c02a, end:0x2000c02d[0m
    [00:00:26.816,986] [0m<dbg> net_mqtt_dec: unpack_uint16: (0x20008430): << val:04d2[0m
    [00:00:26.817,016] [0m<dbg> net_mqtt_dec: unpack_data: (0x20008430): >> cur:0x2000c02c, end:0x2000c02d[0m
    [00:00:26.817,047] [0m<dbg> net_mqtt_dec: unpack_data: (0x20008430): << bin len:00000001[0m
    [00:00:26.817,047] [0m<inf> MQTT_CONNECTION: mqtt_evt_handler: SUBACK packet id: 1234[0m
    [00:00:31.412,628] [0m<inf> MQTT_CONNECTION: version_publish: to topic: iot-2/evt/metadata_req/fmt/text len: 31[0m
    [00:00:31.412,689] [0m<inf> MQTT_CONNECTION: version_publish: mqtt Data: Firmware version: 1.0.0.releas_v1[0m
    [00:00:31.412,689] [0m<dbg> net_mqtt: mqtt_publish: (0x20003948): [CID 0x200085d8]:[State 0x06]: >> Topic size 0x0000001f, Data size 0x00000021[0m
    [00:00:31.412,750] [0m<dbg> net_mqtt_enc: pack_utf8_str: (0x20003948): >> str_size:00000021 cur:0x2000bfad, end:0x2000c028[0m
    [00:00:31.412,780] [0m<dbg> net_mqtt_enc: pack_uint16: (0x20003948): >> val:001f cur:0x2000bfad, end:0x2000c028[0m
    [00:00:31.412,780] [0m<dbg> net_mqtt_enc: mqtt_encode_fixed_header: (0x20003948): << msg type:0x31 length:0x00000042[0m
    [00:00:31.412,841] [0m<dbg> net_mqtt_enc: packet_length_encode: (0x20003948): >> length:0x00000042 cur:(nil), end:(nil)[0m
    [00:00:31.412,841] [0m<dbg> net_mqtt_enc: mqtt_encode_fixed_header: (0x20003948): Fixed header length = 02[0m
    [00:00:31.412,902] [0m<dbg> net_mqtt_enc: pack_uint8: (0x20003948): >> val:31 cur:0x2000bfab, end:0x2000c028[0m
    [00:00:31.412,933] [0m<dbg> net_mqtt_enc: packet_length_encode: (0x20003948): >> length:0x00000042 cur:0x2000bfac, end:0x2000c028[0m
    [00:00:31.412,933] [0m<dbg> net_mqtt: client_write_msg: (0x20003948): [0x200085d8]: Transport writing message.[0m
    [00:00:31.429,809] [0m<dbg> net_mqtt: client_write_msg: (0x20003948): [0x200085d8]: Transport write complete.[0m
    [00:00:31.429,809] [0m<dbg> net_mqtt: mqtt_publish: (0x20003948): [CID 0x200085d8]:[State 0x06]: << result 0x00000000[0m
    [00:00:31.429,840] [0m<inf> MQTT_CONNECTION: MqttSubTask: send version_publish[0m
    [00:00:33.630,798] [0m<inf> MQTT_CONNECTION: metertype_publish: to topic: iot-2/evt/powermeter_type/fmt/text len: 34[0m
    [00:00:33.630,828] [0m<inf> MQTT_CONNECTION: metertype_publish: mqtt Data: Powermeter Type: Aidon-Kaifa[0m
    [00:00:33.630,828] [0m<dbg> net_mqtt: mqtt_publish: (0x20003948): [CID 0x200085d8]:[State 0x06]: >> Topic size 0x00000022, Data size 0x0000001c[0m
    [00:00:33.630,889] [0m<dbg> net_mqtt_enc: pack_utf8_str: (0x20003948): >> str_size:00000024 cur:0x2000bfad, end:0x2000c028[0m
    [00:00:33.630,920] [0m<dbg> net_mqtt_enc: pack_uint16: (0x20003948): >> val:0022 cur:0x2000bfad, end:0x2000c028[0m
    [00:00:33.630,950] [0m<dbg> net_mqtt_enc: mqtt_encode_fixed_header: (0x20003948): << msg type:0x31 length:0x00000040[0m
    [00:00:33.630,981] [0m<dbg> net_mqtt_enc: packet_length_encode: (0x20003948): >> length:0x00000040 cur:(nil), end:(nil)[0m
    [00:00:33.631,011] [0m<dbg> net_mqtt_enc: mqtt_encode_fixed_header: (0x20003948): Fixed header length = 02[0m
    [00:00:33.631,042] [0m<dbg> net_mqtt_enc: pack_uint8: (0x20003948): >> val:31 cur:0x2000bfab, end:0x2000c028[0m
    [00:00:33.631,103] [0m<dbg> net_mqtt_enc: packet_length_encode: (0x20003948): >> length:0x00000040 cur:0x2000bfac, end:0x2000c028[0m
    [00:00:33.631,103] [0m<dbg> net_mqtt: client_write_msg: (0x20003948): [0x200085d8]: Transport writing message.[0m
    [00:00:33.647,735] [0m<dbg> net_mqtt: client_write_msg: (0x20003948): [0x200085d8]: Transport write complete.[0m
    [00:00:33.647,766] [0m<dbg> net_mqtt: mqtt_publish: (0x20003948): [CID 0x200085d8]:[State 0x06]: << result 0x00000000[0m
    [00:00:33.647,766] [0m<inf> MQTT_CONNECTION: MqttSubTask: send metertype_publish[0m
    [00:00:35.655,242] [0m<inf> MQTT_CONNECTION: MqttSubTask: set SerialInfo.wififlag=1[0m

  • Hi,

     

    Dev-ercom said:
    [00:00:14.220,031] [0m<inf> net_mqtt: mqtt_client_init: clean_session is 1[0m

    This indicates that you are encoding with a clean session.

    Based on the zephyr boot banner, you are using v2.3.0.

    This sets the config based on these two:

    https://github.com/nrfconnect/sdk-zephyr/blob/v3.2.99-ncs1/subsys/net/lib/mqtt/mqtt_internal.h#L32

    https://github.com/nrfconnect/sdk-zephyr/blob/v3.2.99-ncs1/subsys/net/lib/mqtt/mqtt.c#L180

     

    And based on my former experiment, although with a mosquitto broker (it seems that you're using a cloud provider), it shows that the "clean" flag is set.

     

    PS: I would recommend that you look into using a newer SDK version. v2.3.0 is quite old, and there has been quite a lot of fixes on nRF7002 since then.

     

    Kind regards,

    Håkon

Related