Matthew R Kasun 3 years ago
parent
commit
4854cb2db9
2 changed files with 3 additions and 2 deletions
  1. 2 1
      mq/mq.go
  2. 1 1
      netclient/functions/daemon.go

+ 2 - 1
mq/mq.go

@@ -156,11 +156,12 @@ func SetupMQTT() mqtt.Client {
 	opts := mqtt.NewClientOptions()
 	broker := servercfg.GetMessageQueueEndpoint()
 	opts.AddBroker(broker)
+	client := mqtt.NewClient(opts)
 	tperiod := time.Now().Add(10 * time.Second)
 	for {
 		if token := client.Connect(); token.Wait() && token.Error() != nil {
 			logger.Log(2, "unable to connect to broker, retrying ...")
-			if time.Now().Afer(tperiod) {
+			if time.Now().After(tperiod) {
 				log.Fatal(0, "could not connect to broker, exiting ...", token.Error())
 			}
 		} else {

+ 1 - 1
netclient/functions/daemon.go

@@ -75,7 +75,7 @@ func SetupMQTT(cfg *config.ClientConfig) mqtt.Client {
 	for {
 		if token := client.Connect(); token.Wait() && token.Error() != nil {
 			logger.Log(2, "unable to connect to broker, retrying ...")
-			if time.Now().Afer(tperiod) {
+			if time.Now().After(tperiod) {
 				log.Fatal(0, "could not connect to broker, exiting ...", token.Error())
 			}
 		} else {