cURL / Mailing Lists / curl-library / Single Mail

curl-library

Cannot connect to a http server after a failed attempt for some time

From: Gustavo Henrique <gustavohenriquesm_at_gmail.com>
Date: Tue, 21 Jan 2014 11:56:36 -0200

Hi,
I'm using libcurl 7.31.0 to do http requests to a server on a machine
located on local network every 3 seconds. It works fine, but if one
connection attempt fails ("Couldn't connect to server" error), when, for
any reason, the server goes down, when it comes back I still cannot connect
to it for some time (keep receiving "Couldn't connect to server error") .
 After some time (about 1 minute), I'm able to connect to it again.

I don't think it's related to the server configuration, because when
testing via browser, this weird behavior is not seen (I'm able to connect
to the server as soon as it goes up).

The code I'm running is:

int main(void) {
CURL *curl;
CURLcode res;
size_t size;
std::string result;
 curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
 curl_easy_setopt(curl, CURLOPT_URL, "http://10.110.6.18");

while(1){
if (curl) {
res = curl_easy_perform(curl);
 /* Check for errors */
if (res != CURLE_OK) {
printf("ERROR! curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
} else {
printf("\nReceived: ");
}
result.clear();
}
sleep(3000);
}
curl_easy_cleanup(curl);
curl_global_cleanup();
    return 0;
}

Any ideas how to solve it?

Thanks

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-01-21