github mochi-mqtt/server v1.3.0

latest releases: v2.6.5, v2.6.4, v2.6.3...
2 years ago

What's Changed - The Big Inflight Messages Release

  • Adds Inflight TTL expiry times for queued inflight messages by @mochi-co as per #86 and #76
  • Periodically resend queued inflight messages to connected clients by @mochi-co as per #86 and #76
  • Fixes long standing flakey test by @mochi-co as per #25
  • Changes to the Persistence interface in order to facilitate cleaning of inflight messages by @mochi-co.
  • Upgrading to this new release will clean any stuck/accumulated QOS messages in your store.

Full Changelog: v1.2.3...v1.3.0


In Discussion Inflight messages cleaning #76 and Issue Stale inflight messages #86 we discovered that for some cases, inflight messages were able to accumulate with no way of purging them from memory or the persistence store (if in use).

The main reasons this occurred were:

  • In order to meet the MQTT 3.1.1 spec, QOS > 0 Publish messages or to QOS > 0 subscriptions are queued for delivery later to clients when they reconnect. If a client never reconnected, the messages would queue indefinitely.
  • Less frequently, QOS messages which failed to resolve were only resent if the client reconnected. If the client never reconnected, they were kept indefinitely.

To this end, the following changes have been implemented:

  • The server internal event loop now periodically attempts resending pending inflight messages to connected clients. After 6 attempts, the inflight message is presumed to be defective/unwanted and dropped. As resends are only attempted with connected clients, this does not affect the expected behaviour of QOS message queueing.
  • An Inflight TTL feature has been added which allows the server to drop any inflight messages which are still queued after a given duration. The server now takes a new InflightTTL option specifying the number of seconds an unresolved message should be kept before being dropped. A new case has been added to the internal event loop to periodically scan the client inflight messages memory and delete any expired inflight messages based on this value.
  • The Persistence interface has been updated to provide a ClearExpiredInflight(expiry int64) error method for clearing expired inflight messages in layers which do not support native TTL solutions (bolt), and a setInflightTTL method used to automatically propagate the known inflight TTL from the server to persistence layers. These interface changes are breaking changes, and as such the minor version has been increased to 3.

For those wishing the set the TTL of their inflights to a specific value, examples/tcp/main.go has a demonstration:

// An example of configuring various server options...
options := &mqtt.Options{
	BufferSize:      0,       // Use default values
	BufferBlockSize: 0,       // Use default values
	InflightTTL:     60 * 15, // Set an example custom 15-min TTL for inflight messages
}

server := mqtt.NewServer(options)

With huge thanks to @Flaer and @bkupidura for their work investigating this issue.

As usual, please open an issue with any concerns, bugs, or ideas! :)

Tests

  • Builds
  • Unit Tests Passing
  • PAHO Interoperability Passing

Don't miss a new server release

NewReleases is sending notifications on new releases.