mqtt-proxy
Accepts MQTT connections of one protocol version and exposes the client id as a variable.
mqtt-proxyPriority 1000What it does
mqtt-proxy lets only the MQTT clients of one protocol version through a stream route. It reads the CONNECT a client sends first and compares the protocol it names with Protocol name, MQTT unless you change it, and the level it names with Protocol level.
A client whose CONNECT matches reaches the broker, and the broker's answer comes back on the same connection. A client whose CONNECT names another level is cut off without a byte.
When to use it
- Sensors that connect with protocol level 4 on
1883to a pool of brokers, while a client of any other level should be cut off at the gateway. - A broker cluster that serves MQTT 5 alone, behind a port that turns older clients away with level 5.
- Old devices that still name the protocol
MQIsdp, kept on a port of their own with level 3.
Not for capping how many connections a device keeps open — see limit-conn (Limits concurrent connections per key) or forwarding connections whatever protocol they speak — see Stream route (Stream routes forward raw TCP and UDP connections to an upstream).
Set it up
Pass connections of clients that speak MQTT protocol level 4 to the broker
A client whose CONNECT names another protocol level is cut off without a byte.
Leave Protocol name at MQTT and set Protocol level to 4.
{
"protocol_name": "MQTT",
"protocol_level": 4
}
Things to know
- Protocol level — With level 4 on a stream route whose server port is 9100, a CONNECT that names level 4 reaches the broker and its answer comes back,
20020000in hex. A CONNECT that names level 5 is closed. - Protocol name — A client whose CONNECT names another protocol is closed without a byte; MQTT 3.1 clients name MQIsdp, every later version MQTT.
- Protocol level — A client whose CONNECT names another level is closed without a byte: MQTT 3.1.1 clients send 4, MQTT 5 clients 5, MQTT 3.1 clients 3.
- Protocol level — A level is required; a plugin without one is refused when you save.
- Protocol level — The level is a whole number:
4.5is refused when you save. - The plugin also takes the client id from the CONNECT and makes it available as a variable.
- AdviceGive each MQTT version a port of its own, and put behind each port the brokers that serve that version.
Settings
The fields as the console shows them, section by section.
protocol_namestringdefault MQTTprotocol_levelintegerRequired