Running multiple ChirpStack Gateway Bridge instances simultaneously

Sorry, Linux dummie here.

I want to migrate to Chirpstack V4 mainly because of the multi region support. So far I was running Chirpstack V3 with a single region.

Chirpstack is running on a Ubuntu 20.04.4 LTS installation running on a VPS. v3 works without any problems.

I already have two toml files for the two regions I want to use.

I was able to use the migration tool to go to V4 and it puts both regions in the new files.

But then, for multiple region support, it seems I need to run multiple instances of the Chirpstack Gateway Bridge:
image

But I have no idea how to do that. Can someone give me a hint how to start the gateway bridge in two instances, each using its own toml configuration?

1 Like

Please note that the chirpstack-gateway-bridge is a single binary, that you can execute multiple times. It takes a -c argument for the configuration file. What you probably want to do is create multiple Systemd services, each per region.

See as an example:

https://github.com/chirpstack/chirpstack-gateway-bridge/blob/master/packaging/files/chirpstack-gateway-bridge.service. This file is copied to /lib/systemd/system/chirpstack-gateway-bridge.service.

Maybe this could be helpful too: Systemd Essentials: Working with Services, Units, and the Journal | DigitalOcean.

1 Like

@brocaar
Thanks, as I said, I am a linux dummy.

So I would change this line

ExecStart=/usr/bin/chirpstack-gateway-bridge

to include the -c xxxx.toml config file, correct?

@brocaar

Thanks a lot, now I have (still on old Chirpstack) two regions working.

I love Chirpstack!!!

1 Like

Does this still work?

I always get an error trying to start a second service. I have even tried to call a duplicate of /usr/bin/chirpstack-gateway-bridge and it still won’t let me start the second service.
Both services work if I only start either of them. They have their own config files as well.

I moved on to CS V4 and Docker installation and there it is very simple to run two (or more) Chirpstack Gateway Bridges through Docker containers.

Here is my installation on a RAKwireless Connect Gateway with RAKPiOS and the following Docker containers

  • Chirpstack V4
  • Three gateway bridges
  • InfluxDB & Grafana for visualization
  • NodeRED for control activities
  • Two UDP Packet Forwarders for two RAK concentrators (EU868 and AS923-3)

I can install this within minutes with a compose.yaml file.

The AS923-3 part is used for my Hydroponic-Control-System
The EU868 part is used for testing.

Hello, can you share your .toml file with the regions and the .service or tell me how you made it work for you?
It gives me an error when trying to run both services.
I created two bridge.toml for the regions I require but I don’t know why I can’t get it to work.
I would appreciate if you could help me with this problem.

I used docker for the setup and wrote a docker YAML file to install everything.

There is a lot of stuff in the YAML file because it installs everything (CS V4, two GW forwarders, postgres, redis, mosquitto, influxdb and grafana)

For the regions, it is this part:

  cs-gw-bridge-eu868:
    image: chirpstack/chirpstack-gateway-bridge:4
    network_mode: host
    restart: unless-stopped
    command: -c /etc/chirpstack-gateway-bridge-eu868/chirpstack-gateway-bridge.toml
    ports:
      - 1701:1701/udp
    volumes:
      - ./configuration/chirpstack-gateway-bridge-eu868:/etc/chirpstack-gateway-bridge-eu868
    environment:
      - INTEGRATION__MQTT__EVENT_TOPIC_TEMPLATE=eu868/gateway/{{ .GatewayID }}/event/{{ .EventType }}
      - INTEGRATION__MQTT__STATE_TOPIC_TEMPLATE=eu868/gateway/{{ .GatewayID }}/state/{{ .StateType }}
      - INTEGRATION__MQTT__COMMAND_TOPIC_TEMPLATE=eu868/gateway/{{ .GatewayID }}/command/#
    depends_on:
      - mosquitto

  cs-gw-bridge-as923-3:
    image: chirpstack/chirpstack-gateway-bridge:4
    network_mode: host
    restart: unless-stopped
    ports:
      - 1700:1700/udp
    volumes:
      - ./configuration/chirpstack-gateway-bridge:/etc/chirpstack-gateway-bridge
    environment:
      - INTEGRATION__MQTT__EVENT_TOPIC_TEMPLATE=as923_3/gateway/{{ .GatewayID }}/event/{{ .EventType }}
      - INTEGRATION__MQTT__STATE_TOPIC_TEMPLATE=as923_3/gateway/{{ .GatewayID }}/state/{{ .StateType }}
      - INTEGRATION__MQTT__COMMAND_TOPIC_TEMPLATE=as923_3/gateway/{{ .GatewayID }}/command/#
    depends_on:
      - mosquitto

I can’t attach the complete YAML file, but you can find it in my Github Hydroponic-Control-System/Docker/docker-compose.yml at main · beegee-tokyo/Hydroponic-Control-System · GitHub

1 Like

Thanks, I’m trying. I created a v4 test server with docker and it works perfectly for me, but when I wanted to migrate the production server I got errors, so I was trying to make it work in chirpstack v3 by creating the services with the regions that I would use.

I think one important point is that you have to connect the different gateway bridges to different UDP ports.

here are the two toml files I am using, one for AS923-3 the other one for EU868. They are quite standard, but, as mentioned, they are listening to different UDP ports.
I can’t attach them as files, there are quite strict limitations for file attachments.

EU868.toml:

# This configuration provides a Semtech UDP packet-forwarder backend and
# integrates with a MQTT broker. Many options and defaults have been omitted
# for simplicity.
#
# See https://www.chirpstack.io/gateway-bridge/install/config/ for a full
# configuration example and documentation.


# Gateway backend configuration.
[backend]
# Backend type.
type="semtech_udp"

  # Semtech UDP packet-forwarder backend.
  [backend.semtech_udp]

  # ip:port to bind the UDP listener to
  #
  # Example: 0.0.0.0:1700 to listen on port 1700 for all network interfaces.
  # This is the listener to which the packet-forwarder forwards its data
  # so make sure the 'serv_port_up' and 'serv_port_down' from your
  # packet-forwarder matches this port.
  udp_bind = "0.0.0.0:1701"


# Integration configuration.
[integration]
# Payload marshaler.
#
# This defines how the MQTT payloads are encoded. Valid options are:
# * protobuf:  Protobuf encoding
# * json:      JSON encoding (easier for debugging, but less compact than 'protobuf')
marshaler="protobuf"

  # MQTT integration configuration.
  [integration.mqtt]
  # Event topic template.
  event_topic_template="eu868/gateway/{{ .GatewayID }}/event/{{ .EventType }}"
  # event_topic_template="gateway/{{ .GatewayID }}/event/{{ .EventType }}"

  # Command topic template.
  command_topic_template="eu868/gateway/{{ .GatewayID }}/command/#"
  # command_topic_template="gateway/{{ .GatewayID }}/command/#"

  # State topic template
  state_topic_template="eu868/gateway/{{ .GatewayID }}/state/{{ .StateType }}"

  # MQTT authentication.
  [integration.mqtt.auth]
  # Type defines the MQTT authentication type to use.
  #
  # Set this to the name of one of the sections below.
  type="generic"

    # Generic MQTT authentication.
    [integration.mqtt.auth.generic]
    # MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
    server="tcp://mosquitto:1883"

    # Connect with the given username (optional)
    username="eu868"

    # Connect with the given password (optional)
    password=""

and my AS923-3 toml:

# This configuration provides a Semtech UDP packet-forwarder backend and
# integrates with a MQTT broker. Many options and defaults have been omitted
# for simplicity.
#
# See https://www.chirpstack.io/gateway-bridge/install/config/ for a full
# configuration example and documentation.


# Gateway backend configuration.
[backend]
# Backend type.
type="semtech_udp"

  # Semtech UDP packet-forwarder backend.
  [backend.semtech_udp]

  # ip:port to bind the UDP listener to
  #
  # Example: 0.0.0.0:1700 to listen on port 1700 for all network interfaces.
  # This is the listener to which the packet-forwarder forwards its data
  # so make sure the 'serv_port_up' and 'serv_port_down' from your
  # packet-forwarder matches this port.
  udp_bind = "0.0.0.0:1700"


# Integration configuration.
[integration]
# Payload marshaler.
#
# This defines how the MQTT payloads are encoded. Valid options are:
# * protobuf:  Protobuf encoding
# * json:      JSON encoding (easier for debugging, but less compact than 'protobuf')
marshaler="protobuf"

  # MQTT integration configuration.
  [integration.mqtt]
  # Event topic template.
  event_topic_template="as923_3/gateway/{{ .GatewayID }}/event/{{ .EventType }}"
  # event_topic_template="gateway/{{ .GatewayID }}/event/{{ .EventType }}"

  # Command topic template.
  command_topic_template="as923_3/gateway/{{ .GatewayID }}/command/#"
  # command_topic_template="gateway/{{ .GatewayID }}/command/#"

  # State topic template
  state_topic_template="as923_3/gateway/{{ .GatewayID }}/state/{{ .StateType }}"

  # MQTT authentication.
  [integration.mqtt.auth]
  # Type defines the MQTT authentication type to use.
  #
  # Set this to the name of one of the sections below.
  type="generic"

    # Generic MQTT authentication.
    [integration.mqtt.auth.generic]
    # MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
    server="tcp://mosquitto:1883"

    # Connect with the given username (optional)
    username=""

    # Connect with the given password (optional)
    password=""