cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Persistent HTTPS connections

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 22 Jan 2007 00:01:56 +0100 (CET)

On Sun, 21 Jan 2007, Andreas Rieke wrote:

> I would like to use cURL for a single persistent HTTPS connection to request
> some information every 5 seconds from a web server. However, cURL seems to
> use a second connection after the first request is done

If it does, then it it because the server closed the connection. Have you
checked the response headers?

> and after that, a third one is used up to ten parallel connections.

parallel? You mean subsequent I guess?

> After that, cURL tries to reuse the first connection, but unfortunately the
> web server has closed that connection in between. Thus, a new connection is
> established.

That's life with connections, they often time out when not used...

> I use libcurl 16.0 from my C++ application under linux. In order to reduce
> the 10 parallel connections to 3, I tried to change CURLOPT_MAXCONNECTS to 3
> directly after calling curl_easy_init

That would have no impact that all. That is only the value of the maximum
number of kept connections in a single handle, it does not change the way how
libcurl tries to always re-using existing connections. In fact, you only risk
getting it to perform worse.

> but unfortunately, this crashed.

That's a bug in 7.16.0 that is fixed since.

> Is this approach - maybe even setting it to 1 - the correct way to force
> cURL to use just one connection?

No.

> If yes, did I do something wrong that cURL crashes or is this a cURL bug? If
> no, how can I get cURL to use just a single persistent connection?

Re-use the same easy handle all the time, and pray that the server side keeps
the connection open for you all the time.

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2007-01-22