Restore discarded item to device queue

Is there any way to configure LoRa Server in order to rollback deviceQueue and fCnt when an transmission timeout is reached?

I am facing this more times that i would like and sharing my log of an uncessess transmissiong followed by an successfull one.

journalctl -u loraserver.service

Case 1: Discarded device Queue Item

level=info 		msg="backend/gateway: rx packet received"
level=info 		msg="device-session saved" dev_addr=e92e3e6f dev_eui=611441a962f80636
level=warning 	msg="frame counters reset" dev_addr=e92e3e6f dev_eui=611441a962f80636
level=info 		msg="rx info sent to network-controller" dev_eui=611441a962f80636
level=info 		msg="device-session saved" dev_addr=e92e3e6f dev_eui=611441a962f80636
Here The logs differ
level=info 		msg="finished unary call with code OK" grpc.code=OK grpc.method=GetDevice grpc.service=ns.NetworkServer grpc.start_time="2018-07-10T15:11:50-03:00" grpc.time_ms=0.346 peer.address="[::1]:58418" span.kind=server system=grpc
level=info 		msg="device updated" dev_eui=611441a962f80636
level=info 		msg="finished unary call with code OK" grpc.code=OK grpc.method=UpdateDevice grpc.service=ns.NetworkServer grpc.start_time="2018-07-10T15:11:50-03:00" grpc.time_ms=1.461 peer.address="[::1]:58418" span.kind=server system=grpc
level=info 		msg="finished client unary call" grpc.code=OK grpc.method=HandleUplinkData grpc.service=as.ApplicationServer grpc.time_ms=8.983 span.kind=client system=grpc

level=info 		msg="device-queue deleted" id=652
level=warning	msg="device-queue item discarded due to timeout" dev_eui=611441a962f80636 device_queue_item_fcnt=1874
Here they become equal again
level=info 		msg="finished unary call with code OK" grpc.code=OK grpc.method=GetDevice grpc.service=ns.NetworkServer grpc.start_time="2018-07-10T15:11:50-03:00" grpc.time_ms=0.356 peer.address="[::1]:58418" span.kind=server system=grpc
level=info 		msg="finished client unary call" grpc.code=OK grpc.method=HandleDownlinkACK grpc.service=as.ApplicationServer grpc.time_ms=5.444 span.kind=client system=grpc
level=info 		msg="device-queue item updated" dev_eui=611441a962f80636 emit_at_time_since_gps_epoch="<nil>" f_cnt=1875 is_pending=true timeout_after="2018-07-10 15:11:50.870593646 -0300 -03 m=+334093.418280297"
level=info 		msg="pending mac-command block set" cid=RXTimingSetupReq commands=1 dev_eui=611441a962f80636
level=info 		msg="backend/gateway: publishing tx packet" qos=0 topic=gateway/c0ee40ffff29382e/tx
level=info 		msg="device-session saved" dev_addr=e92e3e6f dev_eui=611441a962f80636

Case 2: Successfully sent Item

level=info 		msg="backend/gateway: rx packet received"
level=info 		msg="device-session saved" dev_addr=e92e3e6f dev_eui=611441a962f80636
level=warning 	msg="frame counters reset" dev_addr=e92e3e6f dev_eui=611441a962f80636
level=info 		msg="rx info sent to network-controller" dev_eui=611441a962f80636
level=info 		msg="device-session saved" dev_addr=e92e3e6f dev_eui=611441a962f80636
Here The logs differ
level=info 		msg="device-queue deleted" id=653
Here they become equal again
level=info 		msg="finished unary call with code OK" grpc.code=OK grpc.method=GetDevice grpc.service=ns.NetworkServer grpc.start_time="2018-07-10T15:11:52-03:00" grpc.time_ms=0.342 peer.address="[::1]:58418" span.kind=server system=grpc
level=info 		msg="finished client unary call" grpc.code=OK grpc.method=HandleDownlinkACK grpc.service=as.ApplicationServer grpc.time_ms=4.969 span.kind=client system=grpc
level=info 		msg="device-queue item updated" dev_eui=611441a962f80636 emit_at_time_since_gps_epoch="<nil>" f_cnt=1876 is_pending=true timeout_after="2018-07-10 15:11:52.295220924 -0300 -03 m=+334094.842907546"
level=info 		msg="pending mac-command block set" cid=RXTimingSetupReq commands=1 dev_eui=611441a962f80636
level=info 		msg="backend/gateway: publishing tx packet" qos=0 topic=gateway/c0ee40ffff29382e/tx
level=info 		msg="device-session saved" dev_addr=e92e3e6f dev_eui=611441a962f80636

Any sugestion about how to manage this?
Thank you.

I also stuck at this issue. now waiting someone to help us.

1 Like

I have Tried to monitor the deviceQUeue and then clear and reinsert the queue when this warning trigger a watchdog but this have caused an session activation problem in the node’s LMIC.

No lucky until now.

Ohh, yours lora node is lmic library like me. and what kind of yours gateway?

My gateway is Laird Sentrius RG 191. Are you using LoRa WAN 1.0? You are also recieving in RX1?

This probably happens for Class-B / Class-C devices where you have set the ACK timeout in the device-profile. The server will wait the configured number of seconds, before considering the frame as “lost” and will discard this frame when no ACK is received (eg. packet-loss / malfunctioning device). It is up to your application to re-schedule this frame if needed.

As LoRa Server will continue sending the rest of the queue items re-scheduling the lost frame would add it to the end of the queue, which might not always be what you want. Also depending on your application, it could be perfectly fine to drop a couple of frames now and then.

The nACKs are exposed on the MQTT ../ack topic, so you can handle the way would be best for you :slight_smile:

1 Like

But I am using class A devices in my device profile. Not sure if I understand but this ack topic surely will help me. the nACKs and ACKs are both on same topic?

Are the supports Class-B and supports Class-C unchecked in your device-profile? If I remember correctly, the timeout is not set for Class-A and the NS basically waits until the next uplink.

the nACKs and ACKs are both on same topic?

See the acknowledged flag :slight_smile:

{
    "applicationID": "123",
    "applicationName": "temperature-sensor",
    "deviceName": "garden-sensor",
    "devEUI": "0202020202020202",             // device EUI
    "acknowledged": true,                     // whether the frame was acknowledged or not (e.g. timeout)
    "fCnt": 12                                // downlink frame-counter
}
1 Like

Yes they are both unchecked, also the Supports join is unchecked and the frame counter validation is disabled.

This will help me a lot, i have probably skiped this in the docs. Thank you very much.!!