eclipse / paho.mqtt.javascript

paho.mqtt.javascript
Other
1.15k stars 467 forks source link

onMessageArrived callback is not initiating - Message is not receiving #91

Open anilkunchalaece opened 7 years ago

anilkunchalaece commented 7 years ago

I am trying subscribe to a topic on the Adafruit IO. I am getting subscribe success callback but not receiving any messages from the broker.

client = new Paho.MQTT.Client("io.adafruit.com",443,"anil");

        client.onConnectionLost = onConnectionLost;

        client.onMessageArrived = function (message){
                         console.log("onMessageArrived:"+message.payloadString);
              }

        //connect to the client
        client.connect({onSuccess : subscribeFcn,
                        userName : "anilkunchalaece",
                        password : "..",
                         useSSL : true})

         function subscribeFcn(){
                            console.log("connection is done. Now subscribing");
                            client.subscribe("anilkunchalaece/feeds/data",{"onSuccess":subscribeSucessFcn,"onFailure":subscribeFailureFcn,qos:0});
                         }

        function subscribeSucessFcn(){
          console.log("sunscribe Sucees");
        }

        function subscribeFailureFcn(){
          console.log("subscription is failed");
        }

        function onConnectionLost(){
          console.log("lost the Connection");
        }

pahojs

anybody have any idea onMessageArrived callback is not invoking ?

jpwsutton commented 7 years ago

Hi @anilkunchalaece,

The code looks ok to me, can you confirm that messages are being sent correctly to that topic?

You could also try using the Javascript client utility here: https://www.eclipse.org/paho/clients/js/utility/

anilkunchalaece commented 7 years ago

Hi @jpwsutton Thanks for Quick Reply

the topic is correct. i am able to publish to the same topic.. but not receiving any messages while subscribing.

Javascript client utility giving me the error Failed to connect: AMQJS0007E Socket error:undefined. pahoclient

jpwsutton commented 7 years ago

Looks like you're using the wrong path, you want the path to be /mqtt.

I've tested this myself to make sure it works. screen shot 2016-11-30 at 09 23 02