https://netmaker.org logo
Title
l

lively-salesclerk-37295

10/29/2022, 12:03 AM
Is there any chance to support mqtt websocket mode in netclient? This would allow much easier integration with nginx and other http-based reverse proxies on port 443
After further research, it seems like this should be very easy to achieve. The underlying mqtt library in netclient already supports websockets out of the box: https://github.com/eclipse/paho.mqtt.golang > The library also supports using MQTT over websockets by using the ws:// (unsecure) or wss:// (secure) prefix in the URI. You can set mqtt server in websocket mode using this config entry:
protocol websockets
Then you can make netmaker server talk websocket like this:
MQ_HOST: "ws://netmaker-mq"
The only thing left now is to make netclient contact
wss://website.com
. I tried with
SERVER_NAME: "wss://website.com"
but it doesn't seem to attempt any connection at all.
Is this something you would be able to do @jolly-london-20127 et al?
I tried making these changes manually and compiling the client, but it still tries to connect over
mqtts://
, maybe I'm missing something in the codebase. Any help very welcome!
b

bored-solstice-58967

10/29/2022, 4:28 AM
but why do you want to use websocket mode, any particular reason?? i am sure you can configure your reverse proxy to work with current listeners and connect over
mqtts
l

lively-salesclerk-37295

10/29/2022, 6:18 PM
nginx and any other http-based reverse proxies cannot be configured with mqtts, simply because mqtts is a custom tcp protocol wrapped in tls, it is not http
yes, there are workarounds such as running traefik in front of nginx, or two instances of nginx, one of which configured with streams, but this is a very ugly workaround, imo, when you can just use websockets
also, websockets will penetrate restrictive firewalls (e.g. DPI) much better than mqtts
Any thoughts on this one? @User
b

bored-island-21407

11/01/2022, 3:20 PM
not high on priority list imho... either use traefik to reverse proxy or connect directly to the mqtt port and open the appropriate port on the netmaker server firewall.
l

lively-salesclerk-37295

11/01/2022, 10:40 PM
Would you take a PR for it?
b

bored-island-21407

11/01/2022, 10:52 PM
yes