Skip to content

feat(mqtt output): add ws:// and wss:// scheme support#18958

Open
aitorhh wants to merge 1 commit into
influxdata:masterfrom
aitorhh:feat/mqtt-output-websocket-support
Open

feat(mqtt output): add ws:// and wss:// scheme support#18958
aitorhh wants to merge 1 commit into
influxdata:masterfrom
aitorhh:feat/mqtt-output-websocket-support

Conversation

@aitorhh
Copy link
Copy Markdown

@aitorhh aitorhh commented May 21, 2026

Summary

Adds WebSocket (ws://) and WebSocket Secure (wss://) transport support to the MQTT output plugin.

Motivation

Many MQTT brokers (e.g., cloud-hosted or behind ingress controllers) only expose WebSocket endpoints. The MQTT input plugin (mqtt_consumer) already supports ws:// — this brings parity to the output.

Changes

  • plugins/common/mqtt/mqtt_v3.go — preserve ws/wss schemes instead of overriding to tls
  • plugins/common/mqtt/mqtt_v5.go — same fix for the v5 client
  • plugins/outputs/mqtt/sample.conf — document ws:// and wss:// in the scheme list

Notes

The underlying paho.mqtt.golang library already supports WebSocket transport — this change simply passes the scheme through correctly.

Example config

[[outputs.mqtt]]
  servers = ["wss://broker.example.com:443"]
  topic = 'metrics/{{ .Tag "host" }}'
  username = "user"
  password = "${MQTT_TOKEN}"
  insecure_skip_verify = true
  keep_alive = 30
  data_format = "json"

The MQTT output plugin now supports WebSocket connections by preserving
ws:// and wss:// URL schemes instead of overriding them to tls://.

The underlying paho.mqtt.golang library already supports WebSocket
transport - this change simply passes the scheme through correctly.

This enables publishing to MQTT brokers that only expose WebSocket
endpoints (e.g. wss://broker.example.com:443).
@telegraf-tiger
Copy link
Copy Markdown
Contributor

Thanks so much for the pull request!
🤝 ✒️ Just a reminder that the CLA has not yet been signed, and we'll need it before merging. Please sign the CLA when you get a chance, then post a comment here saying !signed-cla

@telegraf-tiger telegraf-tiger Bot added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label May 21, 2026
@telegraf-tiger
Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant