Skip to content
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

Change JettyConnector 'readTimeout' behavior to match socket read tim… #5114

Merged
merged 2 commits into from
Sep 2, 2022

Conversation

daijithegeek
Copy link
Contributor

…eout definition - e.g., ApacheConnector behavior matches it.

  • Read timeout: Time on waiting to receive the first data byte.

The timeout method timeouts the request even if data were already received, capping the query to a maximum execution time.
This behavior is problematic when streaming data over a prolonged duration; the client has already received data bytes, but data continues to flow.

I provided a jetty specific property (jersey.config.jetty.client.totalTimeout) that configures the 'totalTimeout' when required.

…eout definition - e.g., ApacheConnector behavior matches it.

* Read timeout: Time on waiting to receive the first data byte.

The `timeout` method timeouts the request even if data were already received, capping the query to a maximum execution time.
This behavior is problematic when streaming data over a prolonged duration; the client has already received data bytes, but data continues to flow.

I provided a jetty specific property (jersey.config.jetty.client.totalTimeout) that configures the 'totalTimeout' when required.
@@ -314,8 +314,14 @@ private Request translateRequest(final ClientRequest clientRequest) {
request.followRedirects(clientRequest.resolveProperty(ClientProperties.FOLLOW_REDIRECTS, true));
final Object readTimeout = clientRequest.resolveProperty(ClientProperties.READ_TIMEOUT, -1);
if (readTimeout != null && readTimeout instanceof Integer && (Integer) readTimeout > 0) {
request.timeout((Integer) readTimeout, TimeUnit.MILLISECONDS);
request.idleTimeout((Integer) readTimeout, TimeUnit.MILLISECONDS);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Javadoc does not say much about this, but I think this does not exactly have the same meaning than read time out. This method should also have impact in writing (not only read).

However there is no such method to set a read timeout, and this is more correct than before, so it looks good to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Javadoc does not say much about this, but I think this does not exactly have the same meaning than read time out. > This method should also have impact in writing (not only read).

You are right. the timeout may fire when there is a long enough pause during data transfer. I don't know to be honest.
As you say, the situation seems better like this anyway.

Copy link
Member

@jbescos jbescos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@jansupol jansupol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok. The "idleTimeout" does not seem to be exactly the same as "readTimeout", but the behaviour looks similar.

@jansupol jansupol merged commit 77074f1 into eclipse-ee4j:master Sep 2, 2022
@jansupol jansupol added this to the 2.37 milestone Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants