chirpstack / chirpstack-gateway-bridge

ChirpStack Gateway Bridge abstracts Packet Forwarder protocols into Protobuf or JSON over MQTT.
https://www.chirpstack.io
MIT License
422 stars 270 forks source link

Fix missing MQTT QoS initialization to enable QoS 1 and 2 #95

Closed lglenat closed 5 years ago

lglenat commented 5 years ago

Changing the QOS setting in the toml config file currently does not have any effect on the actual QoS used by the MQTT backend. It seems that there has been a regression a while ago during a major refactoring of the architecture.

I am not sure this is the best way of fixing the issue, but it does the job. As for testing, with this fix I was able to have the gateway bridge connected with QoS 1 to AWS IoT.

brocaar commented 5 years ago

Good catch! I have moved this line to the struct initialization :-)

tomasol commented 5 years ago

Hello, this seems not to be fixed i 2.6.2. I can change qos when placing into deprecated [backend.mqtt], but it does not work for [backend.mqtt.auth] mentioned in the documentation.

lglenat commented 5 years ago

Hello, this seems not to be fixed i 2.6.2. I can change qos when placing into deprecated [backend.mqtt], but it does not work for [backend.mqtt.auth] mentioned in the documentation.

Are you sure? I tested today with the latest version and qos = 1 in [backend.mqtt.auth.generic] and it was working fine (see output logs below):

...
INFO[0049] mqtt: publishing message qos=1 topic=gateway/647fdxxx
INFO[0049] mqtt: publishing message qos=1 topic=gateway/647fdxxx
INFO[0049] mqtt: publishing message qos=1 topic=gateway/647fdxxx
INFO[0049] mqtt: publishing message qos=1 topic=gateway/647fdxxx
INFO[0049] mqtt: publishing message qos=1 topic=gateway/647fdxxx
INFO[0049] mqtt: publishing message qos=1 topic=gateway/647fdxxx
INFO[0049] mqtt: publishing message qos=1 topic=gateway/647fdxxx
...
tomasol commented 5 years ago

I found that the problem only occurs when using marshaler="v2_json" . If that's the case, root_run.go#runV2 gets called and qos is read only from the old location [backend.mqtt]. If runV3 is activated, old and new location [backend.mqtt.auth.generic] can be used. This should be highlighted in the documentation or at least made consistent - current documentation uses old marshaller and new qos location.