fix(mqtt): connect to Venus MQTT via nginx websocket #387
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 viahttp://cerbogx/app
it would use thecerbogx
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