ng2-mqtt icon indicating copy to clipboard operation
ng2-mqtt copied to clipboard

cant get subscribe to work

Open toni-h opened this issue 8 years ago • 6 comments

broker allways disconnects me when trying to subscribe. i have it like this:

private onConnected() { console.log('Connected to broker.'); this._client.subscribe('testtopic/', {qos: 1}); } do i make it right?

thank you

toni-h avatar Dec 15 '16 22:12 toni-h

What broker are you using for testing?

AinoL avatar Dec 16 '16 07:12 AinoL

im using broker.mqttdashboard.com port 8000

http://www.hivemq.com/demos/websocket-client/

any idea? do u think theres something wrong with this broker? can test another right now because im not in home.

thank you

toni-h avatar Dec 16 '16 09:12 toni-h

Are you using the same clientId for multiple clients? That will cause a client takeover and a disconnect.

AinoL avatar Dec 19 '16 07:12 AinoL

no im not using. its odd thing that this broker doesnt work. i tried atleast like 3 diffrent brokers and finally found broker that works: test.mosquitto.org i have no idea why this is the case.

toni-h avatar Dec 19 '16 08:12 toni-h

hi, I am facing same issue. We are using personalized broker & multiple client ids. With same configuration, everything was working fine in node while in angular 7, it is giving me above issue. Please let me know if you have any solution. or alternate option for ng2-mqtt.

nikhil-jaunjal avatar Jan 03 '19 09:01 nikhil-jaunjal

Usually this happens when something goes wrong with your settings. Try using onConnectionLost() to see if there's any error. Something like

onConnectionLost(responseObject) {
    if (responseObject.errorCode !== 0) {
      console.log('onConnectionLost:', JSON.stringify(responseObject));
    }
  }

Len0re avatar Mar 19 '19 08:03 Len0re