Closed remster closed 3 years ago
MQTT broker can operate on TCP or WebSocket. And, yes, go-client can instantiate a websocket connection when the broker is behind a websocket server. For e.g mosquitto test servers have both TCP and websocket endpoint. Websocket server operates on port 80 and 443(depends on encrypted or not). https://mqtt.eclipseprojects.io/
In case mqtt.ts (web only) only the websocket connection is supported.
https://github.com/srishina/mqtt.go/blob/cc8c75d9efd75f7cfde96763b8d088d35de13e42/examples/client-pub/main.go#L74
I don't understand. you parse the broker's address
u, err := url.Parse(broker)
how can the broker be behind a websocket in a go-client. When your client is go, you do not connect via websocket do you? You pick the schema based on who you are, not based who the broker is.I can see maybe tha the client would want to select the transport, a go client can't select a websocket transport and webclient can;t select tcp tranport. So i see some schisophreny here. Think of use cases and document in these examples when are you giving the client the choice and when are you giving the broker (the backend) a choice. The client needs to understand whose choice they are exercising.