eclipse / paho.mqtt.javascript

paho.mqtt.javascript
Other
1.14k stars 468 forks source link

On send message a random number of messages are sent #126

Closed R3cycl0r closed 6 years ago

R3cycl0r commented 6 years ago

Don't know if it's normal but I think no, comparing to other mqtt clients, every time I send a message (all Qos = 0 and Retain = true) it is sent a random number of times, at least one time, but sometimes 3, other 10, other 26 and all of them are sent in a little time frame (1-2 seconds in total). I searched here and there but didn't find nothing that could explain this. Is this normal? Is there some parameter that I can adjust to set to just one message sent? Hope I explained the problem, and thanks for all the fatigue and support you put in this project!

jpwsutton commented 6 years ago

Hi, That sounds like very odd behaviour for the Javascript client. A few things that might help us diagnose this would be to see a snippet of the code where you are publishing your message. Also, to figure out if it's the client sending, the broker, or the client's receiving, it would be a good idea to open the network tab in the developer console in the browser, narrow the filter down to web-socket messages and then click on the frames tab to see each message being sent. In the example below, the first two frames are the CONECT and CONNACK packets, followed by three separate PUBLISH packets. If the client were sending many publishes as you are seeing, I would expect to see a Frame per message being sent. screen shot 2017-11-17 at 09 34 05

If the client seems to be sending the correct number of messages at QoS 0, then I would imagine that the issue you are seeing is actually originating in the Broker you are using, or in the Client that is subscribing to the topic.

R3cycl0r commented 6 years ago

Thanks for letting me know the "frames" function of the tool, I discovered some critical things about the messages and found that the function calling "client.send()" was repeating a random number of times each time was called caused by an unwanted loop... so BIG THANK YOU! Sometimes just someone that helps your eyes open is a big hand! keep on!

jpwsutton commented 6 years ago

No worries, glad I could help!

gary101 commented 5 years ago

@R3cycl0r Hi, you said

found that the function calling "client.send()" was repeating a random number of times each time was called caused by an unwanted loop

I am confused by this problem too! My web use cleint.send() and may receive a message for several times sometimes. You said this is "random", but can I make it receive only ONCE ?

Any suggestion is helpful, thanks a lot!