Problem
I successfully build and run a TLS client Example (picow_tls_client_background
executable) from the GitHub, however a simple http GET request takes about 20 seconds. It does not actually depend on the server response: I tested server, that responds empty string at all, and server with about few kb output - no matter, it takes about 20 seconds to make a request.
As the result of debug, I understand, that 99% of the request time takes altcp_connect
- before that, it takes several miliseconds, and after that, starting from the callback, i.e. tls_client_connected
, it takes about millisecond until the request is made:
Pico turned on -- [few ms] -- altcp_connect() -- [19 sec] -- tls_client_connected() -- [1 ms] -- I see comleted incoming request on the server
Tried to solve
I made a reserch, I found that such behaviour, can be caused by lwIP configuration in lwipopts.h
. It already sounds weird, because it probably should been tested by Raspberry Pi developers, who posted the code on GitHub.
So I set #define MEMP_SANITY_CHECK 0
, set
#define LWIP_DEBUG 0
#define ALTCP_MBEDTLS_DEBUG LWIP_DBG_OFF
I also tried to reduce TCP_WND
or\and TCP_MSS
, but any signficant changes produced cmake errors, that something overflows something. However, I reduced a bit that values, without errors at building.
However, all of that actions did not change request time - it still the same.
I also tried (although, as I wroted, this step is passed fast) to connect to ip directly, instead of DNS resolving by hostname, and it still takes same long.