Chirpstack V4 marshaler json

I recently migrating chirpstack v3 to v4, in previous version i use json in gateway as packet forwarder. Now in version 4, i do not know how to configure the app server to accept json instead of protobuf. I already try to put marshaler=json in the chirpstack config, regions config, basic station config, gateway bridge but the appserver still accept protobuf. Any idea how to configure this? Thanks in advance.

The json / protobuf encoding selection is driven by the gateway, ChirpStack will store this state per gateway. That way, you can use json for some gateways, while using protobuf for the others.

You only have to configure this at the gateway side.

1 Like

I am having the exact same problem. I have a RAK gateway that was formerly associated to a ChirpStack v3 stack, and is being tested now with a different, ChirpStack v4 stack (running in the official container). After figuring out that the region must now be encoded as a prefix of the MQTT topic, and disabling the “chirpstack-gateway-bridge” containers in docker-compose because they are irrelevant to my RAK-based setup, I discovered that the v4 Chirpstack no longer recognizes or accepts the JSON payload sent by my RAK gateway over the MQTT topic:

2024-02-06T18:26:41.917877Z  INFO chirpstack::gateway::backend::mqtt: Message received from gateway region_id="au915_1" topic="au915_1/gateway/60c5a8fffe766152/event/up" qos=0 json=false
2024-02-06T18:26:41.918055Z ERROR chirpstack::gateway::backend::mqtt: Processing gateway event error: failed to decode Protobuf message: invalid wire type value: 6 region_id=au915_1 topic="au915_1/gateway/60c5a8fffe766152/event/up" qos=0
2024-02-06T18:26:46.425380Z  INFO chirpstack::gateway::backend::mqtt: Message received from gateway region_id="au915_1" topic="au915_1/gateway/60c5a8fffe766152/event/up" qos=0 json=false
2024-02-06T18:26:46.425562Z ERROR chirpstack::gateway::backend::mqtt: Processing gateway event error: failed to decode Protobuf message: invalid wire type value: 6 region_id=au915_1 topic="au915_1/gateway/60c5a8fffe766152/event/up" qos=0

I fully know that the “invalid wire type value” error is because the brand-new v4 stack is expecting Protobuf but is receiving JSON. The big clue is the json=false at the end of the “Message received…” log line. As seen here, the Chirpstack process does NOT autodetect the JSON payload, contrary to the v3 behavior, and also contrary to the comment by @brocaar .

Since the JSON payload is no longer auto detected, I therefore tried to change the configuration file to tell Chirpstack about the protocol format, like so:

configuration/chirpstack/region_au915_1.toml:

[[regions]]
...
    [regions.gateway]
    ....
        [regions.gateway.backend]
        ....
                [regions.gateway.backend.mqtt]
                    json=true

However, this setting is ignored by Chirpstack, and still fails to detect or expect JSON as payload.

Since this was an experiment, my workaround was to switch my RAK gateway back to protobuf payload, but this was unexpected.

Is this change by design, o a bug?

Please make sure to configure the RAK MQTT output to ChirpStack v4. You can select this in the gateway web-interface.

I would if I could. However, the dropdown list for payload formats in the gateway web GUI does not mention ChirpStack v4 at all, only up to ChirpStack v3. Additionally, I checked the release notes for the newest available firmware at the RAK firmware download URL and they fail to mention any new support for ChirpStack v4 as JSON.

Nowhere in the release notes does it mention any JSON payload change or the possibility that gateways using JSON payloads need to be reconfigured as protobuf or a different JSON version to use v4. It would be nice to add a warning about this.

This is mentioned in the v4 breaking changes document:
https://www.chirpstack.io/docs/v4-breaking-changes.html#gateway-to-chirpstack-mqtt

I know that the WisGateOS2 does support ChirpStack v4, but I don’t know if your gateway model (already) supports it. If it is not supported, then you could:

  • Try to install the ChirpStack MQTT Forwarder on your gateway (many RAK gateways are based on the same MIPS architecture)
  • Use the ChirpStack Gateway Bridge to accept UDP data