cURL / Mailing Lists / curl-users / Single Mail

curl-users

Strange timeout on win32, all the bytes received but library waiting for -1

From: Marius Seritan <mseritan_at_jacent.com>
Date: Tue, 23 Jul 2002 09:12:18 -0700

Hi,

I am trying to use libcurl in one of our projects. Many thanks to the curl community for such a great product!

Most of the transfers occur just fine however after some 20-50 downloads the library may get in this state where it hangs for (literally) 600sec. I set the timeout to 20sec reducing the hang period to that, however I get the following error: Operation timed out with 2508 out of -1 bytes received. The error was probably occuring without the shorter timeout I did not pay attention to that case. The number of bytes received matches the size of the document I am trying to download. The timeout occurs on various documents.

Of course when I turn on debugging this problem goes away. It looks like there is some problem decoding content-length or similar. Any pointers?

More details:
I am using curl-7.9.8 on win32. My application is multithreaded however a specific curl thread is accessed from just one thread. I implemented my own function to write the result to a file. I am using transfers from specified IP addresses or localhost, I do not need to do DNS lookups. I am downloading from a tomcat server and I requested HTTP/1.1, at least the transfers I debugged are re-using the existing socket. Although the application is multithreaded this problem occurs even with just one thread active - the other threads hold curl handles but do not perform any operation on them.

Thanks,

Marius

------- typical API usage, error checking removed ---------------
m_hCurl = curl_easy_init();
rc = curl_easy_setopt(m_hCurl, CURLOPT_WRITEFUNCTION, CurlWriteFunction );
rc = curl_easy_setopt(m_hCurl, CURLOPT_HEADERFUNCTION, CurlHeaderFunction );
rc = curl_easy_setopt( m_hCurl, CURLOPT_FAILONERROR, 1 );
rc = curl_easy_setopt( m_hCurl, CURLOPT_NOPROGRESS, 1 );
rc = curl_easy_setopt( m_hCurl, CURLOPT_COOKIEJAR, "-" );
rc = curl_easy_setopt(m_hCurl, CURLOPT_VERBOSE, 1 );
rc = curl_easy_setopt(m_hCurl, CURLOPT_DEBUGFUNCTION, CurlDebugCallback );
rc = curl_easy_setopt( m_hCurl, CURLOPT_NOBODY, 0 );
rc = curl_easy_setopt( m_hCurl, CURLOPT_POSTFIELDS, pszPostData );
rc = curl_easy_setopt( m_hCurl, CURLOPT_POSTFIELDSIZE, uPostSize );
rc = curl_easy_setopt(m_hCurl, CURLOPT_FILE, out );
char errBuffer[CURL_ERROR_SIZE]; errBuffer[0] = 0;
rc = curl_easy_setopt( m_hCurl, CURLOPT_ERRORBUFFER, errBuffer );

rc = curl_easy_setopt( m_hCurl, CURLOPT_FILETIME, 1 );
 rc = curl_easy_setopt( m_hCurl, CURLOPT_TIMEOUT, 20 );

 rc = curl_easy_setopt( m_hCurl, CURLOPT_WRITEHEADER, &headers );

 int rcDownload = curl_easy_perform(m_hCurl);
 if( rcDownload != 0 ) {
  printf( errBuffer);
 }

 rc = curl_easy_setopt( m_hCurl, CURLOPT_WRITEHEADER, NULL );

 rc = curl_easy_setopt( m_hCurl, CURLOPT_ERRORBUFFER, NULL );

  rc = curl_easy_getinfo( m_hCurl, CURLINFO_FILETIME, plDocumentTime );

 {
  long lSize=0,lHttpCode=0;
  double fConnectTime=0, fTotalTime=0;
  curl_easy_getinfo( m_hCurl, CURLINFO_TOTAL_TIME, &fTotalTime );
  curl_easy_getinfo( m_hCurl, CURLINFO_CONNECT_TIME, &fConnectTime );
  curl_easy_getinfo( m_hCurl, CURLINFO_SIZE_DOWNLOAD, &lSize );
  curl_easy_getinfo( m_hCurl, CURLINFO_HTTP_CODE, &lHttpCode );
  printf( "Exiting curl_easy_perform code %d, bytes %d, connect time %f, xfer time %f\r\n", lHttpCode, lSize, fConnectTime, fTotalTime );
 }

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2002-07-23