title: How to connect to a Mosquitto broker on a Raspberry Pi through web sockets?
body: <p>I am trying to connect to a Raspberry Pi that has the Mosquitto broker installed. The client on the RPi is connected using: </p>
  
  <pre><code>client.connect("127.0.0.1", 1883, 60)
  </code></pre>
  
  <p>I tried to connect to it on my MQTT JavaScript client using the following specifications but I failed: </p>
  
  <pre><code>client = new Paho.MQTT.Client("10.101.125.190", 1883,"myclientid_" + parseInt(Math.random() * 100, 10)); 
  </code></pre>
  
  <p>I also tried changing the port to <code>8080</code> from the JavaScript side but I still failed. If I change the port to <code>8080</code> on the RPi then it won't even connect. </p>
  
  <p>This is the error that I am getting at the moment: </p>
  
  <pre><code>WebSocket connection to 'ws://10.101.125.190:1883/mqtt' failed: Error during WebSocket handshake: net::ERR_CONNECTION_RESET
  </code></pre>
  
  <p>So, what do I need to change to fix this error? The RPi and my JS client are both in the same local network. </p>
  
  <p><strong>Edit</strong>: 
  I forgot to mention that I have already tried this with <code>test.mosquitto.org - 8080</code> and it worked, but as soon as I change the address then I start getting the error.</p>