Closed JiaWeiWong7 closed 1 year ago
If c.options.ConnectRetry
is true
then the client will continue to attempt to reconnect forever. If you want to verify user details then set that to false (opts.SetConnectRetry(false)
) then the token will error.
@MattBrittan , thank for your response.
If c.options.ConnectRetry is true then the client will continue to attempt to reconnect forever.
My initial thought was whether WARN
is better than that DEBUG
in DEBUG.Println(CLI, "Connect failed, sleeping for", int(c.options.ConnectRetryInterval.Seconds()), "seconds and will then retry, error:", err.Error())
.
So, when the user needs to automatically reconnect, he can know the error when connecting.
I'd support that change on the basis that failed to connect to broker, trying next
is already a warning. However it might make more sense to just output the reason the broker connection failed with the existing warning i.e. "connection attempt failed: REASON" because that existing warning is a bit confusing when you have a single broker configured (the most common situation).
My understanding is that we can add a warning like you said "connection attempt failed: REASON" above this line. If so, I will create a PR later.
I was actually suggesting replacing this line but looking again that's actually before the connect packet is sent. So perhaps we should also change this section so that an error is always output (the log entry there was copied from very old releases and it probably makes more sense to always print a warning).
The issue with changing the line you initially proposed is that the client can be configured with multiple brokers and I think we should display issues with connecting to any of them (otherwise the warning output will just be from the last broker we attempt to connect to).
thank you, after SetProtocolVersion, an error is always output and it is clear which broker connection failed.
version:v1.4.1 My application does not export mqtt debug trace. When the user uses the wrong password, no information can be obtained.