ocaml-cohttp icon indicating copy to clipboard operation
ocaml-cohttp copied to clipboard

callv: graceful handling of remote close

Open madroach opened this issue 5 years ago • 2 comments

Hi,

now my problem is about a connection shutdown initiated by the remote server during a pipelined connection (for example because it imposes a limit on requests per connection). This shutdown is only noticed after the next request is already sent to the wire and read_response tries to read from the in channel. It will then fail with Failure "Client connection was closed". This is especially annoying for non-idempotent requests, because the user won't know whether the request has been processed by the server.

It would be better to detect the shutdown as soon as the tcp FIN packet is received and then either attempt a reconnect or fail when the next request is queued.

madroach avatar Feb 23 '20 20:02 madroach

@madroach is there a particular reason why you need pipelining? Pipelining is mostly a misfeature avoided by most http clients. I'd suggest you to do the same here.

rgrinberg avatar Jan 02 '22 19:01 rgrinberg

Hi, thanks for your reply. I chose the wrong wording. The problem is not about pipelining, but only about connection keep-alive. During pipelining, which is currently not supported, it won't occur.

What is missing is a reader that can handle EOF while there is no request on the wire.

I do already have a working pipelining implementation with connection cache sitting around since 2020, which solves this and supports pipelining, which in my mind has legitimate applications. It just needs a bit polishing, then I'll submit a pull request.

madroach avatar Jan 03 '22 09:01 madroach

fixed by #853

madroach avatar Jul 29 '23 20:07 madroach