Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to connect to mqtt broker #14

Open
suma1431 opened this issue Jul 1, 2015 · 0 comments
Open

Unable to connect to mqtt broker #14

suma1431 opened this issue Jul 1, 2015 · 0 comments

Comments

@suma1431
Copy link

suma1431 commented Jul 1, 2015

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>
plz help me out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant