Open schnoberts1 opened 1 month ago
... at 4.5s delay it takes 8 calls before it fails, an interesting multiple of 4. Any hints? I tried moving WifiClient globally but that swaps -3005 errors for -3003 errors on the first re-use:
22:25:36.246 -> Fetching content length from httpforever.com:80
22:25:36.448 -> Return code from connect0
22:25:37.243 -> took=1001ms length: 5124
22:25:38.260 -> Fetching content length from httpforever.com:80
22:25:38.260 -> Return code from TCPSocket::open-3003
22:26:09.251 -> took=31000ms length: -1
31s timeout this time.
Since I've included the code this should replicate well.
... I am also guessing this 30s timeout is in HttpClient since there's no delay on the return from the failed connect.
Note: calling client.stop() does not resolve the issue
The maximum number of TCP connections is 4.
As defined in the file: "mbed_config.h"
#define MBED_CONF_LWIP_TCP_SOCKET_MAX 4
I don't understand why it's so low. Need to recompile locally to have more connections available.
I never have 4 tcp sockets open but I am confident this limit is at the core of the issue. Some clean up isn’t being executed. Increasing the socket count isn’t going to help though as it just puts the issue off.
@schnoberts1 can you try these changes? https://github.com/arduino/ArduinoCore-mbed/pull/912/files
Of course @JAndrassy. I've applied the patch and the issue still remains.
Platform: Giga R1 Arduino Core Mbed 4.1.5 HttpClient: 0.6.1
Here's a sequence of events with a crudely instrumented MbedClient. We connect using ArduinoHttpClient every 1s. Every 5th connection fails with error -3005 from
static_cast<TCPSocket *>(sock)->open(getNetwork());
in theMbedClient::connect() call
. When it fails it takes 30s to return. This is in version 4.1.5. In version 4.1.1 it would never recover and continue to fail until device reboot. There would be no 30s delay. This issue occurs on any http server I've tried. I can continue to connect to the server in the code with python on my Mac with no problems. If I extend the delay so I connect to the server once every 5s the problem goes away. At 4s it reappears.code