TheThingsNetwork / lorawan-stack

The Things Stack, an Open Source LoRaWAN Network Server
https://www.thethingsindustries.com/stack/
Apache License 2.0
979 stars 308 forks source link

Imported device does not seem to keep session alive so no new messages arrive #6858

Closed dajtxx closed 9 months ago

dajtxx commented 9 months ago

Summary

I am trying to move devices between applications. I use the CLI to export the device data and the console to import it.

Steps to Reproduce

  1. Export the device via the CLI. The command is:
ttn-lw-cli dev get dev-xfer-test-1 xfer-1 --name --description --lorawan-version --lorawan-phy-version --frequency-plan-id --supports-join --root-keys --session >ttn.json
  1. Confirm the device and session keys and ul/dl counts are correct by comparing the info on the console to what is in the JSON file.
  2. Delete the device from dev-xfer-test-1 using either CLI or console.
  3. Import the device to dev-xver-test-2 using the console and the JSON file.
  4. Wait for the next uplink. The device sends it but it does not show in the traffic monitor of the console.

Current Result

The device must be restarted so it joins again.

Expected Result

I hoped the next uplink would appear against the the imported device in the new application.

Relevant Logs

This is the exported device. It's all test stuff so I do not mind the keys being exposed.

{
  "ids": {
    "device_id": "xfer-1",
    "application_ids": {
      "application_id": "dev-xfer-test-1"
    },
    "dev_eui": "70B3D57ED0064673",
    "join_eui": "0000000000000000",
    "dev_addr": "260D748D"
  },
  "created_at": "2024-01-24T00:36:26.056072Z",
  "updated_at": "2024-01-24T01:57:07.415449094Z",
  "network_server_address": "au1.cloud.thethings.network",
  "application_server_address": "au1.cloud.thethings.network",
  "join_server_address": "au1.cloud.thethings.network",
  "lorawan_version": "MAC_V1_0_3",
  "lorawan_phy_version": "PHY_V1_0_3_REV_A",
  "frequency_plan_id": "AS_920_923_TTN_AU",
  "supports_join": true,
  "root_keys": {
    "app_key": {
      "key": "2117D8042169D2BA900988792B8EE536"
    }
  },
  "session": {
    "dev_addr": "260D748D",
    "keys": {
      "session_key_id": "AY045iSL8F45SF36HRaYVg==",
      "f_nwk_s_int_key": {
        "key": "1B516D4B0C8D06DAA4AB6CD227EF83DD"
      },
      "s_nwk_s_int_key": {
        "key": "1B516D4B0C8D06DAA4AB6CD227EF83DD"
      },
      "nwk_s_enc_key": {
        "key": "1B516D4B0C8D06DAA4AB6CD227EF83DD"
      },
      "app_s_key": {
        "key": "B01B6AA7ECE95579B546ED40ED1BFB8A"
      }
    },
    "last_f_cnt_up": 10,
    "last_n_f_cnt_down": 1,
    "last_a_f_cnt_down": 1,
    "started_at": "2024-01-24T00:37:09.073192442Z"
  }
}

URL

No response

Deployment

The Things Stack Community Edition

The Things Stack Version

No response

Client Name and Version

The Things Network Command-line Interface: ttn-lw-cli
Version:             3.28.2
Build date:          2023-12-20T13:40:42Z
Git commit:          4a7d6714f
Go version:          go1.21.5
OS/Arch:             linux/amd64

Other Information

Screenshot 2024-01-24 at 12 59 02 pm Screenshot 2024-01-24 at 1 01 26 pm

Proposed Fix

Indicate whether this is supposed to work.

If it should, do I need more info in my JSON?

Contributing

Code of Conduct

dajtxx commented 9 months ago

Hmm, never mind. A few uplink periods later an uplink did appear in the new device. Looks like it missed 2, which is 20 minutes.