Skip to main content

MQTT support

The gateway serves MQTT 3.1.1 and 5.0. Compatibility lists the clients and test suites that we test the gateway with.

Supported​

Feature3.1.15.0Notes
QoS 0yesyesCore NATS
QoS 1 and 2yesyesOnly on topics that a binding stores
Wildcard subscriptions (+, #)yesyes
Shared subscriptions ($share/)yesyesThe gateway grants QoS 1 at most
Retained messagesyesyesNeeds a retained bucket
Persistent sessionsyesyesNeeds a sessions bucket
Session takeoveryesyesWorks across gateways that share the sessions bucket
WillsyesyesA QoS 1 or 2 will needs a bound topic
Will Delay Intervalyes
Server-assigned client IDyesyes
Username and passwordyesyesThe listener maps them to a NATS user
TLS and mutual TLSyesyes
WebSocketyesyes
Message Expiry Intervalyes
User PropertiesyesThe gateway sends them as NATS headers
Content Type, Response Topic, Correlation DatayesThe gateway sends them as NATS headers
Payload Format Indicatoryes
Subscription Identifiersyes
No Localyes
Retain Handling, Retain As Publishedyes
Topic aliasesyes
Receive Maximumyes
Maximum Packet Sizeyes
Server Keep AliveyesSet it with mqtt.server-keepalive
Server Reference on shutdownyesSet it with mqtt.server-reference
Reason codes and reason stringsyesSee Errors
Sparkplug B 3.0yesyesSee Run Sparkplug B clients

Not supported​

  • Enhanced authentication (the v5 AUTH packet)
  • Request/Response Information (v5)
  • QoS 2 shared subscriptions. The gateway grants QoS 1 instead.
  • The $SYS/ broker statistics topics
  • A queue of QoS 0 messages for an offline client

Things to know​

  • QoS 1 and 2 need a binding. The gateway refuses a QoS 1 or 2 publish to a topic that no binding stores. It does not change the publish to QoS 0.
  • One consumer per session per stream. Each session with a QoS 1 or 2 subscription holds one JetStream consumer on each stream that it reads. The max_consumers limit of a stream sets how many of these sessions the stream can serve. The default is 1,000. Past that limit, the gateway refuses the subscription.
  • Duplicates after a failure. After a lost connection or a failed gateway, a QoS 1 or 2 message can arrive again. The second copy can arrive after later messages. If a client must not process a message twice, the client should discard duplicates.
  • Topics are subjects. The topic a/b/c is the NATS subject a.b.c. + is *, and # is >. See MQTT mapping.