Hello All,
First time developing with libcurl and got some unexpected results:
I'm trying to reuse the same CURL handle in order to reuse it's connections
associated with it. However, I noticed a huge performance drop when I
constantly change the Ip address of my request.
When I keep the IP address unchanged everything is fine, I'm pretty sure
there's something I'm missing, but I don't know what and where to search for.
Here's my code:
// curl init
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
&RestClientPool::WriteCallBack); // custom write function
curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, 200L);
// perform request, curl handle is stored and reused
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
curl_easy_setopt(curl, CURLOPT_URL, req_url.c_str()); // here req_url is
something like http://123.123.123.123:8080/api/api
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
CURLcode res = curl_easy_perform(curl);
PS: I can tell that libcurl handle is reusing the connections by monitoring,
because i monitored the servers. So, new connections when ip change shouldn't
be the problem here.
libcurl version:
curl 7.70.0 (x86_64-pc-linux-gnu) libcurl/7.29.0 NSS/3.53.1 zlib/1.2.7
libidn/1.28 libssh2/1.8.0
OS:
CentOS 7.6.1810
Best,
Franky Pan
--
Unsubscribe: https://lists.haxx.se/listinfo/curl-library
Etiquette: https://curl.se/mail/etiquette.html