1
votes

I am using a mosquitto for my broker server, when I use mqtt-react and put my internet's local ip address I get this error in the console:

WebSocket connection to 'ws://192.XXX.X.X:1883/' failed: Error during WebSocket handshake: net::ERR_CONNECTION_RESET

and in my terminal where mosquitto is opened, it says this

Client <unknown> disconnected due to protocol error.

Any ideas appreciated

1
Edit the question to include your mosquitto.conf so we can see if you have configured a Websocket Listener (port 1883 is normally Native MQTT not MQTT over Websockets)hardillb
@hardillb my mosquitto.conf is still all in commentsgassy person

1 Answers

2
votes

MQTT react is trying to use MQTT over Websockets to connect to the broker, this is because it is based in a web browser so the sandbox will only allow HTTP or Websocket connections

By default Mosquitto only starts one listener (on port 1883) which only supports MQTT over TCP. If you want to connect with MQTT over Websockets you will need to add a new listener on a new port. To do this add the following to your mosquitto.conf file:

listener 8083
protocol websockets

You will need to update the URL in your code for the broker to be as follows:

ws://192.XXX.X.X:8083