emqx / emqx-bridge-mqtt

Bridge of MQTT (deprecated since EMQX v5)
https://www.emqx.com
Apache License 2.0
37 stars 13 forks source link

forward_mount point empty or commented out gives different behaviour #103

Closed endianjoakim closed 3 years ago

endianjoakim commented 4 years ago

We hit an issue where if we configure the forward_mount using environment variables, we can only set the value. We can not remove it completely. This is a known issue, https://github.com/emqx/emqx-docker/issues/77. However, we did not expect the different behaviour in setting an empty forward_mount vs commenting the line out of the config file.

EMQX_BRIDGE__MQTT__AWS__FORWARD_MOUNTPOINT="" 
#bridge.mqtt.aws.forward_mountpoint = ""  << Working bridge, as in MQTT messages are correctly passed across
bridge.mqtt.aws.forward_mountpoint = ""   << Non-working bridge, as in no MQTT messages seen over the bridge

The base of the problem is that we can not have a default configuration file mounted in Kubernetes AND use environment variables to override some values, because kubernetes mounts the config as read-only. We need to use the default emqx_bridge_mqtt.conf and override the values. But then you can't comment out settings, and the default value for forward_mountpoint does not work for our use case.

matthewGEA commented 3 years ago

If your mountpoint is "", that is a valid topic as well. You may find that it's not interpreting "" as an empty string but literally as "", which would publish to ""/topic

endianjoakim commented 3 years ago

Well that's the issue. The forward_mountpoint is a prefix for the topics you set in forwards, which means that they should mean the same thing. As I explained, when it's commented out, the topics in forwards are correctly transmitted but not when it's set to "".

Edit: I see I misinterpreted you.

The problem then is that the configuration file does not allow bridge.mqtt.aws.forward_mountpoint =. Thats a parsing error. Same with setting empty environment variables.

endianjoakim commented 3 years ago

I think there is a work around for this in 4.3.0, where you can create a new config directly from environment variables, https://github.com/emqx/emqx/issues/4424#issuecomment-805562578.

Closing.