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