slfan1989 commented on code in PR #8697:
URL: https://github.com/apache/hadoop/pull/8697#discussion_r3888831756
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy/WebAppProxyServlet.java:
##########
@@ -310,7 +310,10 @@ private void proxyLink(final HttpServletRequest req,
base.setHeader(name, value);
}
}
-
+ // Tell the AM/history server to close the connection after the response
+ // so that the proxied connection is not left in CLOSE_WAIT state on the
+ // proxy side (YARN-11845).
+ base.setHeader("Connection", "close");
Review Comment:
This also changes the client-facing connection behavior.
`proxyLink()` copies every header from the upstream response into `resp`, so
when the AM/history server responds with `Connection: close`, that hop-by-hop
header is forwarded to the browser/API client as well.
I verified this by checking `proxyConn.getHeaderField("Connection")` in the
new test, and the client-facing response contains `close`.
Consequently, every proxied request loses keep-alive between the client and
WebAppProxy, contrary to the PR description that only the internal connection
is affected. RFC 9110 Section 7.6.1 also requires intermediaries to remove
`Connection` and other connection-specific fields before forwarding.
Could we instead close the locally created
`CloseableHttpClient/CloseableHttpResponse` with try-with-resources, which
directly addresses the resource lifecycle? If the request header is retained,
the response path should filter hop-by-hop headers and the test should verify
that the client-facing connection is not forced closed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]