Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from

Conversation

lglenat
Copy link
Contributor

@lglenat lglenat commented Nov 21, 2018

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.

@@ -116,6 +116,8 @@ func NewBackend(config BackendConfig) (*Backend, error) {
return nil, fmt.Errorf("mqtt: unknown auth type: %s", config.Auth.Type)
}

b.qos = config.Auth.Generic.QOS
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if it would be better to have this in the Backend instantiation at line 87. Feel free to amend.

@brocaar brocaar closed this in debb7a5 Dec 9, 2018
@brocaar
Copy link
Collaborator

brocaar commented Dec 9, 2018

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

@tomasol
Copy link

tomasol commented Jan 22, 2019

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 lglenat deleted the patch/mqttBackendQos branch January 23, 2019 22:24
@lglenat
Copy link
Contributor Author

lglenat commented Jan 24, 2019

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
Copy link

tomasol commented Jan 24, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants