Adding small coalesce on scheme to ensure backward compatibility in both the pubsub and binding mqtt components
This commit is contained in:
parent
55b6657d1c
commit
810ec429a7
|
|
@ -293,7 +293,15 @@ func (m *MQTT) createClientOptions(uri *url.URL, clientID string) *mqtt.ClientOp
|
|||
opts := mqtt.NewClientOptions()
|
||||
opts.SetClientID(clientID)
|
||||
opts.SetCleanSession(m.metadata.cleanSession)
|
||||
opts.AddBroker(uri.Scheme + "://" + uri.Host)
|
||||
// URL scheme backward compatibility
|
||||
scheme := uri.Scheme
|
||||
switch scheme {
|
||||
case "mqtt":
|
||||
scheme = "tcp"
|
||||
case "mqtts":
|
||||
scheme = "ssl"
|
||||
}
|
||||
opts.AddBroker(scheme + "://" + uri.Host)
|
||||
opts.SetUsername(uri.User.Username())
|
||||
password, _ := uri.User.Password()
|
||||
opts.SetPassword(password)
|
||||
|
|
|
|||
|
|
@ -286,7 +286,15 @@ func (m *mqttPubSub) createClientOptions(uri *url.URL, clientID string) *mqtt.Cl
|
|||
opts := mqtt.NewClientOptions()
|
||||
opts.SetClientID(clientID)
|
||||
opts.SetCleanSession(m.metadata.cleanSession)
|
||||
opts.AddBroker(uri.Scheme + "://" + uri.Host)
|
||||
// URL scheme backward compatibility
|
||||
scheme := uri.Scheme
|
||||
switch scheme {
|
||||
case "mqtt":
|
||||
scheme = "tcp"
|
||||
case "mqtts":
|
||||
scheme = "ssl"
|
||||
}
|
||||
opts.AddBroker(scheme + "://" + uri.Host)
|
||||
opts.SetUsername(uri.User.Username())
|
||||
password, _ := uri.User.Password()
|
||||
opts.SetPassword(password)
|
||||
|
|
|
|||
Loading…
Reference in New Issue