문제

I have developed an application which uploads a file to Dropbox. I am using Libcurl (libcurl-7.21.7) and Openssl (0.9.8e) api’s to upload the file to Dropbox. I have noticed that sometimes my application is crashing because of Server unresponsiveness. The error I get on console is

SSL read: error:00000000:lib(0):func(0):reason(0), errno 131 Closing connection #0

I have implemented the CURL_TIMEOUT in my POST request but still I am facing this crash. If the time out is small I continuously get upload errors, and if it's too long I get then the application crashes giving the above error. Is there a way to address the issue seen in the request to avoid the crash??

On debugging further found that the crash is actually happening in the ssl library becaus of which the application crashes.

Please can some light be thrown on this??

Code I am using is :

CURL *curl;
curl = curl_easy_init();
    curl_global_init(CURL_GLOBAL_ALL);  
    curl_easy_setopt(curl, CURLOPT_CAINFO, NULL);           
    curl_easy_setopt(curl, CURLOPT_CAPATH, NULL);
    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2);
    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
    curl_easy_setopt(curl, CURLOPT_URL,NOTIFICATIONURL);
    curl_easy_setopt(curl, CURLOPT_POST, 1L);
    curl_easy_setopt(curl, CURLOPT_FORBID_REUSE,1);
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS,data());
    curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, datalength);
    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
    long int maxconnectiontime = 600;
    curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT,maxconnectiontime);
    long int maxtime = 1200;
    curl_easy_setopt(curl, CURLOPT_TIMEOUT,maxtime);

    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
    res = curl_easy_perform(curl);

    if(res)  
    {
            log("\n nCURL ERROR curl_easy_perform return %s [%d]",curl_easy_strerror(res),res);
    }  

    curl_slist_free_all(headers);
    curl_global_cleanup();
    curl_easy_cleanup(curl);
도움이 되었습니까?

해결책

The problem can be solved by adding the signals "SIGPIPE" and SIGALRM" in the client code and ignore.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top