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(mqtt): connect to Venus MQTT via nginx websocket #387

Merged
merged 4 commits into from
Jul 22, 2024
Merged

Conversation

mman
Copy link
Collaborator

@mman mman commented Jun 20, 2024

This PR adds support to connect to Venus FlashMQ via nginx mapped websocket instead of using the port 9001.

It is implemented in two parts:

1. HTML 5 app

In the past the HTML5 app used window.location.hostname and hardcoded port 9001 to derive MQTT broker URL from the location where the HTML5 app is loaded. So when it is accessed remotely by connecting to Venus via http://cerbogx/app it would use the cerbogx hostname, and port 9001 to open WebSocket connection directly to FlashMQ web socket port 9001 as configured on Venus in /etc/flashmq/flashmq.conf.

In this new implementation it derives both hostname and port from the window.location and uses special request path /websocket-mqtt to connect to FlashMQ via Venus nginx mapping.

2. MFD Modules part

The MFD modules MqttStore allowed in the past to specify only host and port where to connect to the broker.

In the new implementation it also allows to override request path defaulting to websocket-mqtt so that complete broker URL can be composed. This is addressed in a separate PR here: https://github.com/victronenergy/victron-mfd-modules/pull/4

@mman
Copy link
Collaborator Author

mman commented Jun 20, 2024

The check failing is expected as this code relies on https://github.com/victronenergy/victron-mfd-modules/pull/4 that needs to be tagged first.

@mman mman merged commit 8c861ee into master Jul 22, 2024
1 check passed
@martinbosma martinbosma deleted the websocket-mqtt-fix branch July 22, 2024 13:47
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.

1 participant