-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zuul/Hystrix: HTTP connection leak in case of timeout #127
Comments
@brenuart sounds like a bug, since you are aware of the source of the issue, do you want to send a PR? |
As you say I'm aware of the source of the issue but I have no clue on how to solve it "nicely". 1/ 2/ If the command times out, an Hystrix Timeout exception is thrown and no According to me, the Our (temporary) approach was to slightly modify the But again, someone with better Hystrix and/or Zuul experience may find a better and cleaner approach. |
any news? |
@brenuart @NiteshKant @z0mb1ek We were also experiencing connection leaks with Zuul. The only thing that did help was upgrading the apache-httpclient module and use the Most of this factory code is pretty much sealed and cannot be changed easily, so we had to do many tricks to let this happen (mainly - re-write the NFHttpClientFactory, the NFHttpClient and injecting our factory). So far - so good. Connections leaks are gone, and now we don't see any CLOSE_WAIT connections in netstat. |
@brenuart were you doing something like this in RibbonCommand? : HttpResponse forward() throws Exception {
NFRequestContext context = NFRequestContext.getCurrentContext();
HttpRequest.Builder builder = HttpRequest.newBuilder().
verb(verb).
uri(uri).
entity(requestEntity);
for (String name : headers.keySet()) {
List<String> values = headers.get(name);
for (String value : values) {
builder.header(name, value);
}
}
for (String name : params.keySet()) {
List<String> values = params.get(name);
for (String value : values) {
builder.queryParams(name, value);
}
}
HttpRequest httpClientRequest = builder.build();
HttpResponse response = restClient.executeWithLoadBalancer(httpClientRequest);
context.setZuulResponse(response);
// Here we want to handle the case where this hystrix command timed-out before the
// ribbon client received a response from origin. So in this situation we want to
// cleanup this response (release connection) now, as we know that the zuul filter
// chain has already continued without us and therefore won't cleanup itself.
if (isResponseTimedOut()) {
response.close();
}
return response;
} As that seems like maybe the simplest solution to this - at least I'm not seeing a better way to solve this without significant work. If this sounds ok, I'll merge this in. |
Yes. At least for the part:
|
Handle the case where the hystrix RibbonCommand timed-out before the ribbon client received a response from origin. So in this situation we want to release the connection now, as we know that the zuul filter chain has already continued without us and therefore won't cleanup itself.
Ok, I've merged that change (#225), and done a new patch release - v.1.2.2 |
This issue is still marked 'Open,' but the comments suggest that a bug fix has been merged nearly a year ago. Is this fixed or is it still hanging out there open? |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
See spring-cloud/spring-cloud-netflix#327 for a complete description of the issue and scenarios to reproduce it.
The bottom line is:
The problem has been identified in the
RibbonCommand
returning anHttpResponse
that will never be closed in case of Hystrix timeout. Hence causing connection leaks in the HTTP connection pool.Although the issue affects SpringCloud's version of the Zuul server, it seems that
com.netflix.zuul.dependency.ribbon.hystrix.RibbonCommand
would be affected as well.The text was updated successfully, but these errors were encountered: