bewee / mqtt-bridge

Mozilla Public License 2.0
2 stars 2 forks source link

Change websocket port #1

Open ben-digitalhive opened 3 years ago

ben-digitalhive commented 3 years ago

Hello I have installed your addon in Webthings Gateway and I am assumming I can then use this to publish events to my broker? However it seems to have a hardcoded websocket port of 8080 - is this correct? How can I change this for my particular purposes?

bewee commented 3 years ago

Hi @ben-digitalhive,

Exactly. With this addon, things and co will publish events to your broker.

Please have a look at the README. It describes the setup process, including how to change the URL (which contains the port). The default port is btw 1883. Also, please don't forget to create a local authorization token and give it to the addon, because else it cannot interact with your things :)

Fyi, I also wrote an addon which allows you to run an MQTT broker from within your gateway: mqtt-broker-extension

ben-digitalhive commented 3 years ago

Hi - Thanks for the response. Yes I understand the intent of the addon now and have successfully had it connected to my Home Assistant. Data is flowing - great work!

However what tripped me up when I was playing with this initially and it wasnt working was that it seems to have a hard-coded requirement for port 8080 even though I have specified 1883. The errors in the log look like this:

2021-05-29 01:01:22.236 INFO : mqtt-bridge: Loading add-on mqtt-bridge from /home/pi/.webthings/addons/mqtt-bridge 2021-05-29 01:01:24.179 INFO : mqtt-bridge: Probing port 8080 2021-05-29 01:01:24.369 INFO : mqtt-bridge: MQTT connected 2021-05-29 01:01:24.441 INFO : mqtt-bridge: WebthingsClient lost. Reconnecting in 1 second 2021-05-29 01:01:25.444 INFO : mqtt-bridge: Probing port 8080 2021-05-29 01:01:25.479 INFO : mqtt-bridge: WebthingsClient lost. Reconnecting in 1 second 2021-05-29 01:01:26.480 INFO : mqtt-bridge: Probing port 8080

.....

Compared to an MQTT broker that has both 1883 and 8080 exposed looks like this:

2021-05-29 01:03:17.527 INFO : mqtt-bridge: Loading add-on mqtt-bridge from /home/pi/.webthings/addons/mqtt-bridge 2021-05-29 01:03:17.903 INFO : mqtt-bridge: Probing port 8080 2021-05-29 01:03:18.070 INFO : mqtt-bridge: MQTT connected 2021-05-29 01:03:18.254 INFO : mqtt-bridge: zb-00158d0004876bbf : Subscribed to all events 2021-05-29 01:03:18.267 INFO : mqtt-bridge: zb-00158d0004876bbf : Subscribed to MQTT 2021-05-29 01:03:18.270 INFO : mqtt-bridge: zb-00158d0004876b54 : Subscribed to all events 2021-05-29 01:03:18.274 INFO : mqtt-bridge: zb-00158d0004876b54 : Subscribed to MQTT 2021-05-29 01:03:18.276 INFO : mqtt-bridge: zb-00158d0003539a52 : Subscribed to all events 2021-05-29 01:03:18.277 INFO : mqtt-bridge: zb-00158d0003539a52 : Subscribed to MQTT

bewee commented 3 years ago

Hi @ben-digitalhive,

you're right, there is a somewhat hardcoded dependency for port 8080. It's required because that's where the webthings gateway (by default) provides the interface to interact with its things. I do agree that the log messages you posted above don't make this really clear, and I also think that it would be better to make the webthings port a configurable option as well. Feel free to open a PR improving this behavior if you want to :)