Connect BasicStation to Chirpstack in portainer RAK7391

Hello everyone,

I have a problem connecting BasicStation to Chirpstack Network Server. I am using this portainer templates from RAKWireless and run it on RAK7391.

I try to connect the BasicStation to TTN and it is work successfully, but when I tried to connect it to the Chirpstack Network Server it is always failed. From the template the open port for the Chirpstack Gateway Bridge is on 1700 udp, I think it is for the UDP Packet Forwarder, so I edit the chirpstack.yml and open port 3001 for websocket, I change it like this:

chirpstack-gateway-bridge:
    image: chirpstack/chirpstack-gateway-bridge:3
    restart: unless-stopped
    ports:
      - 3001:3001
    environment:
      - TZ=${TZ:-Europe/London}
      - PUID=${PUID:-1000}
      - PGID=${PGID:-100}
      - INTEGRATION__MQTT__AUTH__GENERIC__SERVERS=tcp://mosquitto:1883
      - BACKEND__TYPE=basic_station
      - BACKEND__BASIC_STATION__BIND=:3001
      - BACKEND__BASIC_STATION__REGION=US915
      - BACKEND__BASIC_STATION__FREQUENCY_MIN=902000000
      - BACKEND__BASIC_STATION__FREQUENCY_MAX=928000000
      - BACKEND__BASIC_STATION__CONCENTRATORS__LORA_STD__FREQUENCY=923300000
      - BACKEND__BASIC_STATION__CONCENTRATORS__LORA_STD__BANDWIDTH=500000
      - BACKEND__BASIC_STATION__CONCENTRATORS__LORA_STD__SPREADING_FACTOR=7
    depends_on: 
      - mosquitto

what I add is this line:

      - BACKEND__TYPE=basic_station
      - BACKEND__BASIC_STATION__BIND=:3001
      - BACKEND__BASIC_STATION__REGION=US915
      - BACKEND__BASIC_STATION__FREQUENCY_MIN=902000000
      - BACKEND__BASIC_STATION__FREQUENCY_MAX=928000000
      - BACKEND__BASIC_STATION__CONCENTRATORS__LORA_STD__FREQUENCY=923300000
      - BACKEND__BASIC_STATION__CONCENTRATORS__LORA_STD__BANDWIDTH=500000
      - BACKEND__BASIC_STATION__CONCENTRATORS__LORA_STD__SPREADING_FACTOR=7

The logs for BasicStation is like this:

2023-06-21 12:38:02.941 [TCE:INFO] Connecting to INFOS: ws://192.168.241.51:3001
2023-06-21 12:38:02.943 [TCE:INFO] Infos: e45f:01ff:febc:9afe e45f:01ff:febc:9afe ws://192.168.241.51:3001/gateway/e45f01fffebc9afe
2023-06-21 12:38:02.944 [AIO:DEBU] [4] ws_close reason=1000
2023-06-21 12:38:02.944 [AIO:DEBU] Echoing close - reason=1000
2023-06-21 12:38:02.944 [AIO:ERRO] Recv failed: NET - Connection was reset by peer
2023-06-21 12:38:02.944 [AIO:DEBU] [4] WS connection shutdown...
2023-06-21 12:38:02.944 [TCE:VERB] Connecting to MUXS...
2023-06-21 12:38:02.946 [TCE:VERB] Connected to MUXS.
2023-06-21 12:38:02.947 [RAL:ERRO] sx1301_conf is empty but a hw setup IS required - no fallbacks
2023-06-21 12:38:02.947 [any:ERRO] Closing connection to muxs - error in s2e_onMsg
2023-06-21 12:38:02.947 [AIO:DEBU] [4] ws_close reason=1000
2023-06-21 12:38:02.947 [AIO:DEBU] Echoing close - reason=1000
2023-06-21 12:38:02.948 [AIO:DEBU] [4|WS] Server sent close: reason=1000
2023-06-21 12:38:02.948 [AIO:DEBU] [4] WS connection shutdown...
2023-06-21 12:38:02.948 [TCE:VERB] Connection to MUXS closed in state -1
2023-06-21 12:38:02.948 [TCE:INFO] INFOS reconnect backoff 10s (retry 1)

And the logs for the Chirpstack Gateway Bridge is like this:

time="2023-06-21T12:37:42.930155675Z" level=info msg="backend/basicstation: router-config message sent to gateway" gateway_id=e45f01fffebc9afe
time="2023-06-21T12:37:42.93092333Z" level=info msg="backend/basicstation: gateway disconnected" gateway_id=e45f01fffebc9afe remote_addr="192.168.241.51:45956"
time="2023-06-21T12:37:52.935183856Z" level=info msg="backend/basicstation: router-info request received" gateway_id=e45f01fffebc9afe remote_addr="192.168.241.51:39122" router_uri="ws://192.168.241.51:3001/gateway/e45f01fffebc9afe"
time="2023-06-21T12:37:52.93873854Z" level=info msg="backend/basicstation: gateway connected" gateway_id=e45f01fffebc9afe remote_addr="192.168.241.51:39132"
time="2023-06-21T12:37:52.939419881Z" level=info msg="backend/basicstation: gateway version received" firmware= gateway_id=e45f01fffebc9afe model=corecell package= protocol=2 station="2.0.6(corecell/stdn)"
time="2023-06-21T12:37:52.940125425Z" level=info msg="backend/basicstation: router-config message sent to gateway" gateway_id=e45f01fffebc9afe
time="2023-06-21T12:37:52.940920672Z" level=info msg="backend/basicstation: gateway disconnected" gateway_id=e45f01fffebc9afe remote_addr="192.168.241.51:39132"
time="2023-06-21T12:38:02.943970152Z" level=info msg="backend/basicstation: router-info request received" gateway_id=e45f01fffebc9afe remote_addr="192.168.241.51:51050" router_uri="ws://192.168.241.51:3001/gateway/e45f01fffebc9afe"
time="2023-06-21T12:38:02.946452964Z" level=info msg="backend/basicstation: gateway connected" gateway_id=e45f01fffebc9afe remote_addr="192.168.241.51:51058"
time="2023-06-21T12:38:02.947052233Z" level=info msg="backend/basicstation: gateway version received" firmware= gateway_id=e45f01fffebc9afe model=corecell package= protocol=2 station="2.0.6(corecell/stdn)"
time="2023-06-21T12:38:02.947428541Z" level=info msg="backend/basicstation: router-config message sent to gateway" gateway_id=e45f01fffebc9afe
time="2023-06-21T12:38:02.948173141Z" level=info msg="backend/basicstation: gateway disconnected" gateway_id=e45f01fffebc9afe remote_addr="192.168.241.51:51058"

Where I do wrong? And is there any documentation to connecting the BasicStation to the Chirpstack Network Server with this portainer templates?

Hi
To use BasicStation with a self-hosted LNS like ChirpStack you need to create the certificates on the LNS first, since BasicStation uses WSS (i.e. over TLS).
You can create the required certificates using chirpstack-certificates repo (GitHub - chirpstack/chirpstack-certificates: Scripts to generate certificates for the ChirpStack components.) and then modify the ChirpStack configuration files (*.toml files) to use them.
Once this is done you can create the gateway certificate and key from the ChirpStack WebUI and use them on the BasicStation service along with the trust certificate created before.
The whole process is somewhat involved, but doable. You can check the specific documentation on the BasicStation docker image we are using here: GitHub - xoseperez/basicstation: Basics™ Station Packet Forward protocol using Docker (that’s for ChirpStack v4, should not be very different for v3).