Open dwarburt opened 6 years ago
FWIW I see the same thing with a simple client that does three things:
If I disconnect "too quickly" the message is never received. I've had to add time.Sleep()
calls into the middle of the steps which is horrid.
Dropping the TLS example almost line-by-line into a test program for AWS IoT caused the server to close the connection when the first subscribe packet is sent.
When I put a time.Sleep(time.Second) in between the cli.Connect and cli.Subscribe calls, then it works just fine. It seems that AWS will close the connection if the subscribe comes too quickly. It seems like the key is to wait until that CONNACK packet is received before continuing with the other messages.
Can we add some sort of event or callback for CONNACK? Like a ConnectedHandler or maybe a buffered channel that sends connection lifecycle events that the main program can read?