• No, you're not doing anything wrong. It's an unfortunate side-effect of the current network abstraction layer... On CC3000, WIZnet, and Linux, the 'connect' function is synchronous - but when using AT commands with ESP8266 it's async.

    As a result, the connect function completes immediately and then if the connection fails the error code is reported by send/recv functions - but the 'connected' callback has already been called.

    It's particularly annoying in bare TCP/IP sockets, but the majority of people just use HTTP. In that case, the connected handler gets called only after the headers have been received - so in reality there is no real difference in the way it works at all.

    You're also getting two disconnected handlers though? I'll check up on that - I've seen that before and wasn't sure about it. It must be some kind of regression.

About

Avatar for Gordon @Gordon started