The blocking nature of TCPClient.connect() is a well documented issue in the forum, specifically the hardcoding of the timeout.
Am testing a corner case of using a bad IP address and this is giving a 5 second blockage (as expected).
To work around this long blockage, I tried setting a timer that kicks off after 250 mS just before the call to .connect(). The timer callback calls TCPClient.stop(), hoping that this would circumvent the block, but it does not.
I’d just try it and see. I give it maybe a 50% chance of working. The inside of the connect call of synchronous, but there isn’t a guard mutex around it, so maybe you can interrupt it. But it’s deep in the bowels of WICED and the code is hard to follow so I’d just try it and see if you can interrupt it.