Skip to content

Commit

Permalink
bug with edgeConnectorMQTTv3
Browse files Browse the repository at this point in the history
  • Loading branch information
geoff-nunan committed Aug 1, 2021
1 parent 91e8419 commit a01ff87
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
9 changes: 5 additions & 4 deletions common/drivers/edgeConnectorMQTTv3.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,28 +72,29 @@ func (s *edgeConnectorMQTTv3) Connect(connInfo map[string]interface{}) error {
}
}
}
s.LogDebug("ServiceName = "+svcName)
if err != nil {
panic("Failed to find configuration data for MQTT connection")
}

opts := mqtt.NewClientOptions()
opts.SetUsername(user)
opts.SetPassword(pwd)
opts.SetOrderMatters(false)
opts.SetKeepAlive(30 * time.Second)
opts.SetPingTimeout(2 * time.Second)
useTls, err = strconv.ParseBool(useTlsStr)
if err != nil {
panic(fmt.Sprintf("Bad value for MQTT_USE-SSL in configuration for PlcConnectorMQTT: %s", useTlsStr))
}
if useTls {
tlsConfig := newTLSConfig()
opts.AddBroker("ssl://"+server)
opts.SetClientID(svcName).SetTLSConfig(tlsConfig)
opts.SetTLSConfig(tlsConfig)
//conn, err = tls.Dial("tcp", server, nil)
} else {
//conn, err = net.Dial("tcp", server)
opts.AddBroker("tcp://"+server)
opts.SetClientID(svcName)
opts.SetKeepAlive(2 * 60 *time.Second)
opts.SetPingTimeout(1 * time.Second)
}
if err != nil {

Expand Down
6 changes: 1 addition & 5 deletions common/drivers/plcConnectorMQTTv3.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (
mqtt "github.com/eclipse/paho.mqtt.golang"
"io/ioutil"
"log"
"os"

//"os"

//"net"
Expand Down Expand Up @@ -85,9 +83,7 @@ func (s *plcConnectorMQTTv3) Connect() error {
if err != nil {
panic("Failed to find configuration data for MQTT connection")
}
mqtt.ERROR = log.New(os.Stdout, "[ERROR] ", 0)
mqtt.CRITICAL = log.New(os.Stdout, "[CRIT] ", 0)
mqtt.WARN = log.New(os.Stdout, "[WARN] ", 0)

opts := mqtt.NewClientOptions()
opts.SetUsername(user)
opts.SetPassword(pwd)
Expand Down

0 comments on commit a01ff87

Please sign in to comment.