cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Timeout & crash Issue

From: <Gunn_Fergal_at_emc.com>
Date: Mon, 22 Mar 2004 17:52:44 -0000

What we are trying to do is set up a https request to a service which should
respond promptly. What we are seeing though is that intermittently the
response does not come back and the code is blocked waiting for the service
to return. It was my understanding that when using the
"curl_easy_setopt(curl,CURLOPT_TIMEOUT,300);"
setting that the curl_easy_perform would be interrupted and the code could
continue, after 5 mins in the above code (300 seconds).

Am I correct in my assumption here or am I missing something from my curl
setup.

    CURL *curl;
    ostringstream outbuf;
    string url;
    curl = curl_easy_init();
    if (curl != NULL)
    {
        struct curl_slist *headers=NULL;
        url = secure ? "https://" : "http://";
        url += m_host;
        url += secure ? "" : ":8000";
        url += "/servlets/Manager" ;
        curl_easy_setopt(curl, CURLOPT_URL,url.c_str());
        headers = curl_slist_append(headers, "Content-Type: text/xml");
        string user = "EMCXMPUser: " + m_uname;
        headers = curl_slist_append(headers, user.c_str());
        headers = curl_slist_append(headers, "CNNXMPAction: mtr");

        if (secure)
        {
            curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);
            curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 1);
        }
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS,m_XmlString.c_str() );
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,&curl_write_hook);
        curl_easy_setopt(curl,CURLOPT_FILE,&outbuf);
        curl_easy_setopt(curl,CURLOPT_TIMEOUT,300);
        char errorBuf[CURL_ERROR_SIZE];
        curl_easy_setopt(curl,CURLOPT_ERRORBUFFER,&errorBuf);

        int status = curl_easy_perform(curl);
        if (status == 0)
        {
            outbuf.put('\0'); // terminate the string
            string out = outbuf.str();
            int index = out.find_last_of("</Packet>");
            xml_data = out.substr(0,index+1);
        }
        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
    }

On Mon, 22 Mar 2004 Gunn_Fergal_at_emc.com
<mailto:Gunn_Fergal_at_emc.com?Subject=RE:%20Timeout%20&%20crash%20Issue>
wrote:

> Has anyone any information though on the timeout issue. It still seems to
> not return from the request after the timeout period. Do I need to use
> CURLOPT_TIMEOUT in conjunction with another setting??

Please provide more details on how we can proceed and repeat this problem in

our ends!

-- 
    Daniel Stenberg --  http://curl.haxx.se/ <http://curl.haxx.se/>  --
http://daniel.haxx.se/ <http://daniel.haxx.se/> 
   [[ Do not send mails to this email address. They won't reach me. ]]
 
Received on 2004-03-22