diff --git a/common/drivers/edgeConnectorMQTTv3.go b/common/drivers/edgeConnectorMQTTv3.go index 6915967..2ed7828 100644 --- a/common/drivers/edgeConnectorMQTTv3.go +++ b/common/drivers/edgeConnectorMQTTv3.go @@ -72,6 +72,7 @@ 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") } @@ -79,6 +80,9 @@ func (s *edgeConnectorMQTTv3) Connect(connInfo map[string]interface{}) error { 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)) @@ -86,14 +90,11 @@ func (s *edgeConnectorMQTTv3) Connect(connInfo map[string]interface{}) error { 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 { diff --git a/common/drivers/plcConnectorMQTTv3.go b/common/drivers/plcConnectorMQTTv3.go index a5757c7..56a5afe 100644 --- a/common/drivers/plcConnectorMQTTv3.go +++ b/common/drivers/plcConnectorMQTTv3.go @@ -10,8 +10,6 @@ import ( mqtt "github.com/eclipse/paho.mqtt.golang" "io/ioutil" "log" - "os" - //"os" //"net" @@ -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)