TinyMQTT messages not fully delivered #6374
Replies: 1 comment
-
Posted at 2020-04-12 by Moray I put some debugging code into a copy of TinyMQTT.js, and in each case with the problem MQTT messages the first byte of data (or sometimes the first two bytes of data) is/are missing. Good receipt:
Bad receipt, it is received as two separate calls to the data handler in TinyMQTT (onDat):
We can see that if these were received in a single call to onDat, the publish command would be good. Looking at the code for TinyMQTT, I don't think the issue can be in there, it must be somewhere else - any thoughts on where to look next? Or any thoughts on a sensible workaround, maybe compelling the socket to wait a little longer for data somehow - but looks like that code is maybe built into the firmware in the net module. In the meantime I have put in a horrible hack so that if it is a publish command (3) with a total length of less than 5 bytes - which should never happen in my setup - then it stores up to 4 bytes in state waiting for the next call, and prepends these to the second set of data it receives. Here is the hacked replacement onDat function for TinyMQTT.js
All kinds of things could go wrong with this approach, especially if new messages are received in quick succession so I don't really want to live with it long-term. Posted at 2020-04-14 by @gfwilliams Thanks - it sounds like you may be hitting this bug: https://github.com/olliephillips/tinyMQTT/issues/30 There's some code in there that may help? I was waiting for it to get merged into the main TinyMQTT so I could get it in Espruino's version. Posted at 2020-04-14 by Moray Thanks definitely same bug. Your solution is better as I couldn't be bothered to figure out the length calculations, though with a packet size of less than 127 I could have taken it easy:-> Posted at 2020-12-31 by @MaBecker @moray can you please try again. https://github.com/MaBecker/tinyMQTT Posted at 2021-01-01 by @allObjects @MaBecker, do you have fully featured test bed for tinyMQTT as at https://github.com/MaBecker/tinyMQTT ? Posted at 2021-01-02 by @MaBecker
I use a local installed mqtt server , MQTTBox to obserrve and some js snippets. To fix the last issue a snipped given by Gordon was used.
Simple test frame
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2020-04-12 by Moray
I'm using TinyMQTT in a home automation project on a Pico + ESP8266.
About 20% of the time when handling new messages to subscribed topics, my message events fire but do not contain the topic or message, meaning I am unable to handle the message properly.
Subscribing using mosquitto_sub to check what is going on shows that the messages are definitely there and look normal, so this is an issue on the Pico side.
As a workaround I am sending an error back in the case of a null topic so that the UI can ask the user to try again but this is not satisfactory.
The fact it happens only a proportion of the time for identical messages suggests to me that it might be some kind of latency issue reading the data.
Anyone seen anything like this before with TinyMQTT? I am loth to switch to the much heavier MQTT, although I haven't tried it to see if it behaves better yet.
Beta Was this translation helpful? Give feedback.
All reactions