Closed sohneg closed 1 year ago
FIX: I removed opts.SetKeepAlive(60)
and it worked
@sohneg Argument of SetKeepAlive is time.Second instead of int. https://pkg.go.dev/github.com/eclipse/paho.mqtt.golang#ClientOptions.SetKeepAlive
So, you can write opts.SetKeepAlive(60 * time.Second)
As @tomatod says calling opts.SetKeepAlive(60)
effectively sets keepalives to 0 seconds (because the option is a time.Duration
and 60 nanoseconds will be rounded down to 0 seconds). Mosquitto (v2+) will not, by default, accept a keepalive of 0 (which means no keepalives) so it refuses the connection.
I'm surprised that your code would work with a single subscription...
Closing as this behaviour is expected when Keepalive is 0 (well not quite as the OP wrote but I can't duplicate the behaviour originally reported).
I try to subscribe to multiple topics. But it won't work.
What could cause this error? If i change it back to the single Subscribe it works.
Client options:
How i use it:
What Mosquitto says: