shamblett / mqtt5_client

A server and browser based MQTT 5 client for dart
Other
50 stars 26 forks source link

Do not clear messageStream, was loosing messages. #27

Closed SkuggaEdward closed 2 years ago

SkuggaEdward commented 2 years ago

Our situation is that we are sending messages pretty often and we were loosing received messages. I could see that the package on the network and then traced it into this part where messageStream actually contained more than one message and only first was actually handled.

I moved the clear() into the else part as it seemed to help when reconnecting.

Note. Why was sending a lot causing this? There is a lot of ack's being received and the sent message gets aggregated with one or more ack's.

shamblett commented 2 years ago

OK thanks I'll have a look at this over the next few days.

shamblett commented 2 years ago

OK, looking at this what we should really be doing here is messageStream.shrink(), not messageStream.clear(). This is what the mqtt_client package does. This package was based on the mqtt_client package, unfortunately it does not have the full range of fixes that have subsequently been applied to mqtt_client, this is something I must really address for the future.

For now I've updated master branch with the fix, if you could ref this in your pubspec yaml and test it that would be great, I need to do more testing myself before I can re release the package.

shamblett commented 2 years ago

Work for this included on #31