Locate the Network session key in the database

Personal or application server ChirpStack saves the activation values ​​(network session key, device address and application session key) in which table? When viewing databases through pgAdmin 4 and DBeaver, you cannot find them. I’ve already looked at all the bank tables.

The Nwk Session Key is stored in Redis by the ChirpStack Network Server.

1 Like

What are the values ​​saved within the “lora: ns: device: xxxxxx” key in redis?

It is the binary representation of the device-session (Protobuf). Please refer to the source-code (internal/storage/...) for more information :slight_smile: There is a SaveDeviceSession and GetDeviceSession function which will do the save / retrieval.

Is it possible to get this out of redis with chirpstack v4 instead of using the rpc api for a lookup?

Edit: Oops, wrong keys.

But, you are subject to the Redis format changing underneath you. I would strongly recommend using the API for a stable interface.

i’m after a quicker way to sync the network session keys with helium on a device join etc, unfortunately this key is not kept in the postgres device keys table. you must call the device activation rpc which means it should be in the redis db just no way to retrieve it that i know of atm.

This is the code that reads the device-session from Redis, you could replicate the same in your preferred language:

As @bconway already mentioned, this implementation might change over time…

1 Like

Thanks, I will check it out once i get back from vacation I missed the notification you replied to this. I did manage to get it working with the api grpc call.

iirc the main thing i was having issue with was which protobuf was required to decode the session key message if it was not called through the rpc api. I will have another play next week :wink: