Polyglot will not work under docker -- browser tries to connect to wss://MQTT_HOST:3000/
sjthespian opened this issue · 0 comments
After pulling my hair out trying to get polyglot-v2 working in a docker container, I tracked down the problem. The current browser-side javascript is attempting to connect to MQTT_HOST on HOST_PORT (ex. wss://127.0.0.1:3000/). This will work fine if the docker containers are running on the host network or if docker isn't being used at all. However, it will not work on a separate docker network or if a separate MQTT server is being used. It also requires a custom certificate, as the generated certificates do not include the FQDN of the docker host. Setting MQTT_HOST to the docker host and exposing port 1883 will also not work, as it caused MQTT to fail to connect due to the certificates not containing the docker host FQDN.
In order to get things working, I added a new configuration value, HOST_FQDN. This should be set to the FQDN of the host, and shouldn't need to be set if docker is not being used. There is code in settings.js to create a new config attribute for fqdn, and to add the fqdn to the auto-generated certificates. Since I have existing certificates in the database and use a custom wildcard cert on my system, I have not tested this.
You can see my changes in a diff with my fork: https://github.com/UniversalDevicesInc/polyglot-v2/compare/edev...sjthespian:edev?expand=1
I hacked in changes to the browser-side javascript in my fork, I'm sure this really belongs in whatever is generating those two files, but I don't see an obvious place that they come from. These changes switch from using mqttHost to the new fqdn value.