add checks/logs on broker connect timeout

This commit is contained in:
Matthew R. Kasun
2022-05-19 09:11:56 -04:00
parent 3c35eceda7
commit 9a9f1b973e
4 changed files with 51 additions and 1 deletions

View File

@@ -242,6 +242,14 @@ func setupMQTT(cfg *config.ClientConfig, publish bool) mqtt.Client {
} else {
err = token.Error()
}
brokerErr := checkBroker(cfg.Server.Server)
if brokerErr.Error() == "dns" {
logger.FatalLog("dns lookup failed for broker ... update dns records")
} else if brokerErr.Error() == "ping" {
logger.FatalLog("unable to connect to broker ... check firewalls")
} else if brokerErr != nil {
logger.Log(0, "unable to conncet to broker")
}
logger.Log(0, "could not connect to broker", cfg.Server.Server, err.Error())
if strings.Contains(err.Error(), "connectex") || strings.Contains(err.Error(), "connect timeout") {
logger.Log(0, "connection issue detected.. attempt connection with new certs")