cURL / Mailing Lists / curl-library / Single Mail

curl-library

Early initialization errors

From: René Berber <rene.berber_at_gmail.com>
Date: Tue, 06 Mar 2012 18:40:54 -0600

Hi,

This is not a new subject, I've read similar threads but found no way to
fix it so far.

The problem: A http connection is being aborted in libcurl with the
CURLE_FAILED_INIT error code. The problem is caused by the server
having DNS based redundancy, in this case hosts returns 8 IPs (non
distinct, 1 repeats), resulting in a very short time-out which I think
causes a signal when libcurl is just starting.

I understand, from reading other posts, that the CURLOPT_TIMEOUT which
in this case is set to 30 sec is being divided by 8, so the real
time-out used is 3.75 sec.

Now the connection most of the times works, when the response is less
than 3 sec, but sometimes fails creating another problem: some of the
sockets are left in a CLOSE_WAIT state forever (well, until the
application uses the 1024 available file descriptors). On one test 6
sockets where left after curl_easy_cleanup().

I already tried CURLOPT_MAXCONNECTS set to 1, nothing changed.

First question: am I correct assuming CURLE_FAILED_INIT was caused by a
time-out?

Any hints on what can be done to alleviate the problem, or fix it?

I wouldn't mind modifying libcurl to leave the CURLOPT_TIMEOUT alone, in
this use case it doesn't make sense connecting to all IPs, or modifying
the timeout (I do understand the logic behind that decision, you do not
want to have say 8 times the timeout if each IP is tried one after the
other, but they are tried in parallel if I understood the documentation).

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-03-07