cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Link between curl_easy handle and connection

From: Pierre Brico <pierre.brico_at_gmail.com>
Date: Mon, 7 Mar 2016 10:58:09 +0100

Hi Daniel,

I've identified the issue I have. The web application I'm benchmarking is
located behind a loadbalancer which forwards the requests to 2 different
web servers. When a new connection is established between the client and
one of the 2 servers, the loadbalancer adds a new cookie (which name is
'server'). This cookie contains information about the web server which
serves the current session and the loadbalancer uses it to forward
subsequent connections requests to the right server.

So my problem is that libcurl manages its own connections pool. In this
pool, there are connections to the web server 1 and the web server 2 but
each virtual user has its HTTP session on one server (there is no
replication between web servers). So, for example, if libcurl takes a
connection to server 1 and the virtual user has its current HTTP session on
server 2, the web application blocks the request because the user is not
authenticated on this server...

If this is not something you want to change in libcurl, could you help me
pointing out in the sources where I can change this behavior?

Thanks a lot again,
Pierre

On Mon, Mar 7, 2016 at 12:15 AM, Daniel Stenberg <daniel_at_haxx.se> wrote:

> On Sun, 6 Mar 2016, Pierre Brico wrote:
>
> each virtual users has its own CURL handle. When the user wants to
>> communicate with the server, it uses the CURL handle. But it seems that
>> when starting a transfer, libcurl gets a connection from a pool, execute
>> the transfer and put it back to the pool (this suppose HTTP 1.1 protocol).
>>
>
> That is correct. The multi handle owns the pool of connections and once an
> individual easy handle's transfer is completed, the connection is put back
> into the "community pool" free for any (other) easy handle to grab to use
> for the next transfer.
>
> BUT as the user authenticates with one connection, it can't use another
>> connection to send request to the server.
>>
>
> That's not how HTTP is designed to work so then it'll break like this.
> HTTP authenticates requests, not connections. Unless you're Microsoft, but
> we have code in place to work around those particular quirks (NTLM).
>
> So my question is: is it possible to link one connection to one CURL
>> handle (no pool usage)?
>>
>
> In theory it should be fairly easy to have each easy handle use its own
> connection pool, as that is already what libcurl does when using the easy
> interface - there's just no way to tell libcurl to act like that. We've not
> seen users request this before so it hasn't been made possible.
>
> --
>
> / daniel.haxx.se
> -------------------------------------------------------------------
> List admin: https://cool.haxx.se/list/listinfo/curl-library
> Etiquette: https://curl.haxx.se/mail/etiquette.html

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-03-07