rails-reverse-proxy icon indicating copy to clipboard operation
rails-reverse-proxy copied to clipboard

Connection: keep-alive pauses the request

Open ujh opened this issue 6 years ago • 3 comments

When I proxy a request that sends Connection: keep-alive then the proxy pauses for ~20 seconds before sending the proxied data back to the client. I can get around by doing this:

reverse_proxy "http://example.com", { "CONNECTION" => "close"}

I do not know if this should be handled by the gem by default. There's some code that filters out the connection header from the data that comes back from the proxied side but not here. No idea if that's just an oversight.

ujh avatar Oct 14 '19 09:10 ujh

Do you know if the server is hanging for the ~20 seconds or is it the gem/client?

axsuul avatar Oct 14 '19 19:10 axsuul

I think it is the gem / http client. The app behind the proxy returns immediately (it's a sub 1s response). Adding log statements right before and after the reverse_proxy call in the controller method it seems to hang right there. I also measured in the controller method the time the reverse_proxy method took to rule out caching of log statements and that says 20 seconds as well. Obviously that's not a 100% investigation so I'm not totally sure where the problem is located.

ujh avatar Oct 15 '19 06:10 ujh

I ran into the same issue described here, fyi.

kented avatar Dec 03 '19 01:12 kented