MQTT Preread#

Enables extracting client IDs and usernames from CONNECT packets for Message Queuing Telemetry Transport (MQTT) versions 3.1.1 and 5.0.

When building from the source code, the module must be enabled with the build parameter --with-stream_mqtt_preread_module. In packages and images from our repositories, the module is included in the build.

Configuration Example#

Choosing a server in a group by client ID:#

stream {

    mqtt_preread on;

    upstream mqtt {
        hash $mqtt_preread_clientid;
        # ...
    }
}

Directives#

mqtt_preread#

Syntax

mqtt_preread on | off;

Default

mqtt_preread off;

Context

stream, server

Controls extracting information from CONNECT packets during the preread phase. If the parameter is enabled (on), the variables listed below are populated in the context where it is specified.

Built-in Variables#

For detailed description of value semantics, see the MQTT protocol specification versions 3.1.1 and 5.0.

$mqtt_preread_clientid#

Unique client identifier.

$mqtt_preread_username#

Optional username.