-
Notifications
You must be signed in to change notification settings - Fork 357
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
Jersey Apache Connector can hang #4321
Comments
One option is to keep behaviour of Jersey 2.28 for Apache HttpClient 4.5 and the behaviour of Jersey 2.29 for Apache HttpClient 4.5.1+. Optionally, this default behaviour can be overridden. Another option is to close the entity stream in an executor service thread with a timeout, but I am worried about performance, then. |
@agherardi Any thoughts? |
I have a question (apologies - I am no longer working with Jersey. so I cannot easily test this myself):
|
@agherardi Correct. |
Thanks. Then I can think of the following scenarios that cause close() to hang:
I like the idea of giving the client application a way to specify whether close() should either:
So @jansupol 's approach looks good to me. My only suggestion would be to rename the closing strategies to something that's easier to understand - for instance "graceful close" vs "immediate close". |
@agherardi Sorry to hear you no longer use Jersey. To answer your question, in the case of I filed an issue to the Apache JIRA. |
So as far as I understand it, Apache says SSE (Part of HTML5) violates the HTTP protocol. SSE uses |
@jansupol I am entitled to speak on behalf of the ASF or even Apache HttpComponents but such as my interpretation of the HTTP specification. |
@agherardi Thank you for looking into this. I agree that |
@jansupol Being HTML5 specification compliant does not relieve SSE server endpoints from having to respect the HTTP specification requirements with regards to connection persistence and re-use. |
@jansupol up to you, of course, but I'd focus on the behavior - graceful vs immediate close - rather than the version. With httpclient 4.5.1+ you can implement both graceful and immediate close. Can you implement both with < 4.5.1, possibly eating up the exception? If yes, great. If not, you can throw an exception if the app tries to set a close mode that is not supported. After doing that, you can decide what the default close mode should be. On a different note: The choice between graceful and immediate close is independent of the underlying stack - it is not an httpclient "thing". So perhaps the option should be generic rather than Apache-connector specific? |
@ok2c If I read your comment correctly, you recommend not to close the content stream, only the response, the way it is described in the Apache Documentation. The connection is not reusable, but it is not the main issue. The bigger issue I find is that the server side does not get notified that the connection is closed even when the client is closed in that case. |
@agherardi I like the idea of having the closing mechanism generic, but for the other connectors this is not needed to be set, so far this seems to be Apache Connector specific. As I have dug deeper, there can be multiple options on how the user prefers to close the connection, so I prefer to have an interface that is to handle the close, and the user can provide whatever solution is preferred, based on timeout properties, given request URL, or other options. That way the names of the strategies do not need to be thought about... |
@jansupol Why? The content stream never closes the underlying socket. The socket is closed by the response object if the content stream has not been fully consumed. |
@ok2c In the case only a |
@jansupol This looks like a server side issue. |
I think the issue is solved by #4338. The |
We had reportings that Jersey Apache Connector can throw an exception:
And for Apache Http Client 4.5.1+, the Apache Connector as it was in Jersey pre 2.29 stopped working since Apache changed the way the connection is closed.
So the Apache Connector has been changed in 2.29, so that it works with Apache Connector 4.5.1+ and MalformedChunkCodingException can be thrown.
However, the Apache Connector can hang now:
The current issue is when migrating from Jersey pre 2.29 to 2.29, the connection hang as the timeout is not set.
The text was updated successfully, but these errors were encountered: