Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.

Documentationbreadcrumb arrow Grafana k6breadcrumb arrow JavaScript APIbreadcrumb arrow k6/x/mqttbreadcrumb arrow Clientbreadcrumb arrow Client.publish( topic, payload, [options] )
Open source

Client.publish()

Publish a message synchronously.

Signature

JavaScript
client.publish(topic, payload, options)

Parameters

ParameterTypeDescription
topicstringTopic to publish to
payloadstring | ArrayBufferMessage payload (string or binary data)
optionsobjectOptional publish configuration
options.qosnumberQuality of Service level (0, 1, or 2). Default: 0
options.retainbooleanWhether the message should be retained by the broker. Default: false
options.tagsobjectCustom tags for metrics (key-value pairs)