axsuul / rails-reverse-proxy

A reverse proxy for Ruby on Rails
MIT License
237 stars 59 forks source link

Connection: keep-alive pauses the request #34

Open ujh opened 4 years ago

ujh commented 4 years ago

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.

axsuul commented 4 years ago

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

ujh commented 4 years ago

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.

kented commented 4 years ago

I ran into the same issue described here, fyi.