Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Paho » Having trouble getting connection to iot.eclipse.org (javascript)
Having trouble getting connection to iot.eclipse.org (javascript) [message #1702835] Sat, 25 July 2015 13:40 Go to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 2
Registered: July 2015
Location: Massachusetts
Junior Member
I get the following error when attempting to connect the client to the broker on iot.eclipse.org:

onConnectionLost:AMQJS0005E Internal error. Error Message: Invalid argument:object, Stack trace: Paho.MQTT</Client/this.send@file:///C:/test/mqttws31.js:1925:43
onConnect@file:///C:/test/test2.html:29:3
Paho.MQTT</ClientImpl.prototype._handleMessage@file:///test/mqttws31.js:1242:37
Paho.MQTT</ClientImpl.prototype._on_socket_message@file:///C:/test/mqttws31.js:1151:7
Paho.MQTT</scope/<@file:///C:/test/mqttws31.js:157:4

This is the code I'm using. Any help would be greatly appreciated. I've been at this for a while but have yet to be successful. Thanks,

var client = new Paho.MQTT.Client("ws://iot.eclipse.org/ws","bsilverm" + new Date().getTime());
console.log(client);

client.onConnectionLost = onConnectionLost;
client.onMessageArrived = onMessageArrived;

client.connect({onSuccess:onConnect});

function onConnect() {
  console.log("onConnect");
  client.subscribe("/Test");
  message = new Paho.MQTT.Message("Hello");
  message.destinationName = "/Test";
  client.send(message); 
}

function onConnectionLost(responseObject) {
  if (responseObject.errorCode !== 0) {
    console.log("onConnectionLost:"+responseObject.errorMessage);
  }
}

function onMessageArrived(message) {
  console.log("onMessageArrived:"+message.payloadString);
}
Re: Having trouble getting connection to iot.eclipse.org (javascript) [message #1703097 is a reply to message #1702835] Tue, 28 July 2015 14:20 Go to previous messageGo to next message
James Sutton is currently offline James SuttonFriend
Messages: 71
Registered: July 2015
Member
Hi,

I've just tried your code and it seems to work for me:
app.js:10 onConnect
app.js:24 onMessageArrived:Hello

Just to make sure, are you using the latest mqtt31.js from http://git.eclipse.org/c/paho/org.eclipse.paho.mqtt.javascript.git/plain/src/mqttws31.js?
Re: Having trouble getting connection to iot.eclipse.org (javascript) [message #1703119 is a reply to message #1703097] Tue, 28 July 2015 16:25 Go to previous message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 2
Registered: July 2015
Location: Massachusetts
Junior Member
Thanks for the reply. I had to remove the "var" in my client declaration. That seemed to fix the problem and allow me to call the client from outside of the global context.
Previous Topic:Paho Java, M2JE problem, compliling my program
Next Topic:How to retrieve MqttService Binder
Goto Forum:
  


Current Time: Fri Mar 29 06:00:16 GMT 2024

Powered by FUDForum. Page generated in 0.06852 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top