- 
                Notifications
    
You must be signed in to change notification settings  - Fork 61
 
Open
Description
I have installed HiveMQ and running on my machine, from javascript client am trying to connect, but getiing floowing error WebSocket connection to 'ws://192.168.1.100:8000/mqtt' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED in chrome , below is the code am using
<script src="../bower_components/jquery/dist/jquery.min.js"></script> <script src="../js/mqttws31.js"></script> <script src="../js/mqttws31-min.js"></script> <script src="../js/reconnecting-websocket.js"></script> <script src="../js/reconnecting-websocket.min.js"></script> <script>// Create a client instance
client = new Paho.MQTT.Client("192.168.1.100", 8000, "100");
//var s = new ReconnectingWebSocket("ws://192.168.1.100:1883");
// set callback handlers
client.onConnectionLost = onConnectionLost;
client.onMessageArrived = onMessageArrived;
// connect the client
client.connect({onSuccess:onConnect});
// called when the client connects
function onConnect() {
    alert("connected");
  // Once a connection has been made, make a subscription and send a message.
  console.log("onConnect");
  client.subscribe("/World");
  message = new Paho.MQTT.Message("Hello");
  message.destinationName = "/World";
  client.send(message); 
}
// called when the client loses its connection
function onConnectionLost(responseObject) {
  if (responseObject.errorCode !== 0) {
    console.log("onConnectionLost:"+responseObject.errorMessage);
  }
}
// called when a message arrives
function onMessageArrived(message) {
  console.log("onMessageArrived:"+message.payloadString);
} 
</script>
Metadata
Metadata
Assignees
Labels
No labels