commit 5be95b6428c62e9b59b03609753a33e55228dc83
parent abf364034c66df9ed090c476ed76fc9e87a3067c
Author: Natasha Kerensikova <natgh@instinctive.eu>
Date: Mon, 24 Mar 2025 19:49:01 +0000
MQTTS support
Diffstat:
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/mqttagent.go b/mqttagent.go
@@ -455,6 +455,7 @@ func registerMqttClientType(L *lua.LState) {
type mqttConfig struct {
Connection string
+ TLS bool
PauseTimeout string
AtLeastOnceMax int
ExactlyOnceMax int
@@ -492,8 +493,16 @@ func newClient(config *mqttConfig, id string) (*mqtt.Client, error) {
pto = time.Second
}
+ var dialer mqtt.Dialer
+
+ if config.TLS {
+ dialer = mqtt.NewTLSDialer("tcp", config.Connection, nil)
+ } else {
+ dialer = mqtt.NewDialer("tcp", config.Connection)
+ }
+
processed_cfg := mqtt.Config{
- Dialer: mqtt.NewDialer("tcp", config.Connection),
+ Dialer: dialer,
PauseTimeout: pto,
AtLeastOnceMax: config.AtLeastOnceMax,
ExactlyOnceMax: config.ExactlyOnceMax,