[erlang-questions] inets HTTP client does not persist connections when POSTing

Ingela Anderton Andin <>
Mon Aug 4 10:47:21 CEST 2008

Hi Edward, a quick look at the HTTP-spec makes me believe you got a 
valid point.
The current http client has gradually evolved from a user contribution 
and in the processes
you may say it was totally rewritten, and we may have missed an aspect 
here. (E.i. only used
persistent connections for pipelined requests). But I do not
have all details about this fresh in my memory as this was some time 
ago. We will have to take
deeper look into this.  I have put it on the todo-list.  There are a few 
things that has
higer priority right now but i hope we can deal with this issue fairly soon.

Regards  Ingela- Erlang/OTP, Ericsson

> I am using the inets HTTP client to POST many requests to the same URL. I am
> finding that even though keep-alive is set, and persistent connections are
> the default for HTTP 1.1 (which is what I am using), the inets HTTP client
> is opening a new connection for every http:request(post,...) I send. I
> verified this by using Wireshark to monitor the TCP/IP traffic. When there
> is a lot of activity involving multiple clients, this causes ephemeral port
> exhaustion because of the infamous TIME_WAIT problem. I have already reduced
> the TCP wait time to 30 seconds and don't want to reduce it more.
> I read the inets code, and if I understand it correctly, it seems that when
> a non-idempotent operation such as POST is performed, httpc does not reuse
> the existing connection (httpc_manager:select_session/4 returns
> no_connection, which starts a new handler). I am not sure if this is the
> correct thing to do, because my understanding is that the restriction on
> non-idempotent operations applies to pipelining, not persistent connections.
> I can see no reason why one should not be able to do a series of consecutive
> POSTs on the same socket, as long as one waits for a reply before posting
> the next request.
> I'm not sure if this is a bug, a feature, or my misunderstanding, so I am
> posting to this mailing list in the hope that someone, whose name may or may
> not be Ingela, can enlighten me and perhaps suggest how I can use inets to
> do multiple sequential POSTs on a persistent connection.
> I'm using OTP R12B-3 on Ubuntu Linux 8.04. The http:request call uses all
> default HTTP and TCP/IP options (i.e. empty lists).
> Regards,
> Edwin Fine

More information about the erlang-questions mailing list