chirpstack / chirpstack-docker

Setup ChirpStack using Docker Compose
https://www.chirpstack.io/
MIT License
273 stars 316 forks source link

Error message of EnqueueMulticastGroupQueueItemRequest() using python gRPC #86

Open stathisioannides opened 1 year ago

stathisioannides commented 1 year ago

On a Docker Chirpstack ver. 4.3 , the example "nqueue_downlink.py" (https://www.chirpstack.io/docs/chirpstack/api/python-examples.html#enqueue_downlinkpy) works fine.

When we try to execute the following python code for multicast downlink :

server = "localhost:8080"
dev_eui = "0080e1150546f8eb"
api_token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJjaGlycHN0YWNrIiwiaXNzIjoiY2hpcnBzdGFjayIsInN1YiI6ImMyOGM5M2I4LTdlNWMtNGYzOS1hZTA2LWFlNDU3ZjYxNzcwNiIsInR5cCI6ImtleSJ9.7cbczN8WJ5ZNGoQwjZwFLaHiBThGDMJ-1T_uaUTT2F4"
data = [ 0x84, 0x9b, 0x00, 0x08, 0x00, 0x02, 0x01 ]
mcast_group_id = "4b2b9d7c-776f-4e54-b81d-d17178d6d558"

channel = grpc.insecure_channel(server)
client = api.DeviceServiceStub(channel)
auth_token = [("authorization", "Bearer %s" % api_token)]

req = api.EnqueueMulticastGroupQueueItemRequest()
req.queue_item.data = bytes(data)
req.queue_item.f_port = 2
req.queue_item.multicast_group_id = mcast_group_id
resp = client.Enqueue(req, metadata=auth_token)

We are getting the folowing error message :

Traceback (most recent call last):
  File "/root/spyros/lora/sandbox/lora_send.py", line 69, in <module>
    multicast(server, dev_eui, 2, api_token, mcast_group_id, data)
  File "/root/spyros/lora/sandbox/lora_send.py", line 49, in multicast
    resp = client.Enqueue(req, metadata=auth_token)
  File "/root/.pyenv/versions/test1/lib/python3.9/site-packages/grpc/_channel.py", line 1030, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "/root/.pyenv/versions/test1/lib/python3.9/site-packages/grpc/_channel.py", line 910, in _end_unary_response_blocking
    raise _InactiveRpcError(state)  # pytype: disable=not-instantiable
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
    status = StatusCode.INTERNAL
    **details = "failed to decode Protobuf message: DeviceQueueItem.f_port: EnqueueDeviceQueueItemRequest.queue_item: invalid wire type: LengthDelimited (expected Varint)"
    debug_error_string = "UNKNOWN:Error received from peer  {grpc_message:"failed to decode Protobuf message: DeviceQueueItem.f_port: EnqueueDeviceQueueItemRequest.queue_item: invalid wire type: LengthDelimited (expected Varint)", grpc_status:13, created_time:"2023-07-05T12:30:54.699263412+03:00"}"**

When we try the "EnqueueMulticastGroupQueueItemRequest()" with Node_Red it works fine.

Does anybody knows about this error message ?