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

WebSocketClient connect / upgrade timeout not configurable #5018

Closed
michaelkwan opened this issue Jul 3, 2020 · 7 comments · Fixed by #5031
Closed

WebSocketClient connect / upgrade timeout not configurable #5018

michaelkwan opened this issue Jul 3, 2020 · 7 comments · Fixed by #5031

Comments

@michaelkwan
Copy link

michaelkwan commented Jul 3, 2020

Jetty version
9.4.28
Java version
1.8.0.252
OS type/version
Centos 6
Description
WebSocketClient.connect(...) creates WebSocketUpgradeRequests with indefinite timeout. Even with the Future.cancel(), it would not cancel the requests.

This also leads to a big problem because: When the HttpDestination exchange queued exceeded, no new requests can be added. The requests stay in the queue forever.

Reproduction steps:

  1. Set HttpClient MaxConnectionsPerDestination = 1 and MaxRequestsQueuedPerDestination = 1
  2. Asynchronously create 20 simultaneous connections (to the same server)
  3. Observed the HttpDestination queued is full and the request would never dequeue without the timeout

No new requests can be made, as queue is full.

@lachlan-roberts
Copy link
Contributor

@michaelkwan there is no per request configuration for this but you can configure the timeouts through the WebSocketClient or HttpClient.

There is WebSocketClient.setConnectTimeout() and WebSocketClient.setMaxIdleTimeout() which just delegates to set these on the HttpClient. The idleTimeout set by WebSocketClient.setMaxIdleTimeout() is also used as a default for new WebSocket connections.

@michaelkwan
Copy link
Author

michaelkwan commented Jul 3, 2020

@michaelkwan there is no per request configuration for this but you can configure the timeouts through the WebSocketClient or HttpClient.

There is WebSocketClient.setConnectTimeout() and WebSocketClient.setMaxIdleTimeout() which just delegates to set these on the HttpClient. The idleTimeout set by WebSocketClient.setMaxIdleTimeout() is also used as a default for new WebSocket connections.

@lachlan-roberts The connect timeout is the timeout for initializing the connection, not for the initial http upgrade request
I m not talking about the websocket messages, so the idle timeout is of no use here.

Please take a look the WebSocketUpgradeRequest is a HttpRequest. The initial value for timeout is 0.

@michaelkwan
Copy link
Author

@lachlan-roberts Also, like I mentioned, even thou I use WebSocketClient.connect() and Future.get(Time), when you do future.cancel(true), the request stays in the httpexchange queue forever if you exceeded both the maxconnectionsperdestination and maxRequestsQueuedPerDestination and is unrecoverable unless you shutdown the client.

@lachlan-roberts
Copy link
Contributor

@michaelkwan It will be simple enough to add the request timeout to the ClientUpgradeRequest.

I think the Future was intended as more of a notification that the Session was available rather than a way to cancel the websocket handshake. This could be tricky to implement because the future isn't completed until the websocket connection and session has been opened.

@lachlan-roberts
Copy link
Contributor

@michaelkwan take a look at PR #5024 and let me know what you think.

@michaelkwan
Copy link
Author

@michaelkwan take a look at PR #5024 and let me know what you think.

@lachlan-roberts thanks, i think that's sufficient.

lachlan-roberts added a commit that referenced this issue Jul 7, 2020
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit that referenced this issue Jul 7, 2020
and increase timeouts used for testing

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit that referenced this issue Jul 8, 2020
…equestTimeout

Issue #5018 - add request timeout onto ClientUpgradeRequest
lachlan-roberts added a commit that referenced this issue Jul 8, 2020
…ail upgrade

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit that referenced this issue Jul 8, 2020
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit that referenced this issue Jul 8, 2020
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit that referenced this issue Jul 8, 2020
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit that referenced this issue Jul 15, 2020
…ntRequestTimeout

Issue #5018 - add WebSocketClient UpgradeRequest timeout to jetty 10
@joakime joakime changed the title WebSocketClient upgrade request timeout not configurable WebSocketClient connect / upgrade timeout not configurable Jul 22, 2020
lachlan-roberts added a commit that referenced this issue Jul 22, 2020
…tConnectFuture

Issue #5018 - cancellation of WebSocketClient.connect Future should fail upgrade
lachlan-roberts added a commit that referenced this issue Jul 23, 2020
…ail upgrade

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
@lachlan-roberts
Copy link
Contributor

@michaelkwan we have also addressed the issue about cancelling the future in PR #5030, now if the Future is cancelled it will also abort the upgrade request.

Both these fixes will be in the 9.4.31 release which should be out in the next week or so.

leonchen83 pushed a commit to leonchen83/jetty.project that referenced this issue Aug 3, 2020
…uld fail upgrade

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
leonchen83 pushed a commit to leonchen83/jetty.project that referenced this issue Aug 3, 2020
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
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 a pull request may close this issue.

2 participants