Grpc fails with unknown service

Same error message as in

Rpc error: code = Unimplemented desc = unknown service ns.NetworkServerService (code: 2).

My Chirpstack is started with as a docker container using https://github.com/chirpstack/chirpstack-docker/blob/v3/ (so, Chirpstack v3), with just the ports: - 8080:8080 statement changed to ports: - 8081:8080 (A different service is already bound to port 8080 on my system.)

My Python packages are

chirpstack-api==3.12.4
protobuf==3.20.3
grpcio==1.60.0

My script

#!/usr/bin/env python3

import os
import grpc
from chirpstack_api.ns import NetworkServerServiceStub
from chirpstack_api.ns.ns_pb2 import CreateMACCommandQueueItemRequest, GetServiceProfileRequest

host = "127.0.0.1:8081"

channel = grpc.insecure_channel(host)
ns = NetworkServerServiceStub(channel)

x = GetServiceProfileRequest()
x.id = bytes.fromhex("a37664ba-a32a-4df2-965f-6be6bf9e7e60".replace("-", ""))
#x.name = "service"
print("Sending command")
adr_algos = ns.GetServiceProfile(x)
print("Done")

Outputs

Sending command
Traceback (most recent call last):
  File "/home/max/sf_fixer/./sf_fixer.py", line 24, in <module>
    adr_algos = ns.GetServiceProfile(x)
  File "/home/max/.local/lib/python3.10/site-packages/grpc/_channel.py", line 1160, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "/home/max/.local/lib/python3.10/site-packages/grpc/_channel.py", line 1003, in _end_unary_response_blocking
    raise _InactiveRpcError(state)  # pytype: disable=not-instantiable
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
        status = StatusCode.UNIMPLEMENTED
        details = "unknown service ns.NetworkServerService"
        debug_error_string = "UNKNOWN:Error received from peer ipv4:127.0.0.1:8081 {created_time:"2024-01-23T14:10:59.347840581+01:00", grpc_status:12, grpc_message:"unknown service ns.NetworkServerService"}"

Which is inexplicable to me, because I do match the v3 chirpstack-api Python package with a running Chirpstack v3.

The frontend is regularly reachable.

The ns.NetworkServerService is the gRPC service exposed by the chirpstack-network-server service. I assume your application is connecting to the public API of the chirpstack-application-server service, and thus it responds with an error that the requested services is unknown.

1 Like

You were right. Devilish that by default the network server’s gRPC API is not exposed in the docker environment. I modified mine to do

  chirpstack-network-server:
    image: chirpstack/chirpstack-network-server:3
    volumes:
      - ./chirpstack_conf/chirpstack-network-server:/etc/chirpstack-network-server:ro
    ports:
      - 8083:8000
    depends_on:
      - postgresql
      - mosquitto
    networks:
      - infra-net

aka, expose the network server’s API that’s by default on port 8000 as port 8083 on my machine. Change the port in the script, and now it does return something.

$ /bin/python3 /home/max/sf_fixer/sf_fixer.py
Sending command
Done
service_profile {
  id: "T\350\316a\0271J^\220\217\360\224\356\203\007\213"
  add_gw_metadata: true
  dr_max: 5
}
created_at {
  seconds: 1706182035
  nanos: 737825000
}
updated_at {
  seconds: 1706182035
  nanos: 737825000
}
1 Like