Sfoglia il codice sorgente

remove hardcoded 8883

afeiszli 3 anni fa
parent
commit
712c3c8c93
2 ha cambiato i file con 10 aggiunte e 2 eliminazioni
  1. 5 1
      netclient/functions/daemon.go
  2. 5 1
      netclient/functions/mqpublish.go

+ 5 - 1
netclient/functions/daemon.go

@@ -204,7 +204,11 @@ func NewTLSConfig(server string) *tls.Config {
 func setupMQTT(cfg *config.ClientConfig, publish bool) mqtt.Client {
 	opts := mqtt.NewClientOptions()
 	server := cfg.Server.Server
-	opts.AddBroker("ssl://" + server + ":8883") // TODO get the appropriate port of the comms mq server
+	port := "8883"
+	if server.MQPort != "" {
+		port = server.MQPort
+	}
+	opts.AddBroker("ssl://" + server + ":" + port) // TODO get the appropriate port of the comms mq server
 	opts.SetTLSConfig(NewTLSConfig(server))
 	opts.SetClientID(ncutils.MakeRandomString(23))
 	opts.SetDefaultPublishHandler(All)

+ 5 - 1
netclient/functions/mqpublish.go

@@ -132,7 +132,11 @@ func publish(nodeCfg *config.ClientConfig, dest string, msg []byte, qos byte) er
 	}
 
 	if token := client.Publish(dest, qos, false, encrypted); !token.WaitTimeout(30*time.Second) || token.Error() != nil {
-		logger.Log(0, "could not connect to broker at "+nodeCfg.Server.Server+":8883")
+		port := "8883"
+		if nodeCfg.Server.MQPort != "" {
+			port = nodeCfg.Server.MQPort
+		}
+		logger.Log(0, "could not connect to broker at "+nodeCfg.Server.Server+":"+port)
 		var err error
 		if token.Error() == nil {
 			err = errors.New("connection timeout")