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

Asssociate timeout to underlying Jetty HTTP client #24007

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -43,6 +43,7 @@
import org.springframework.web.socket.adapter.jetty.JettyWebSocketSession;
import org.springframework.web.socket.adapter.jetty.WebSocketToJettyExtensionConfigAdapter;
import org.springframework.web.socket.client.AbstractWebSocketClient;
import org.springframework.web.socket.server.HandshakeFailureException;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;

Expand Down Expand Up @@ -156,7 +157,12 @@ public ListenableFuture<WebSocketSession> doHandshakeInternal(WebSocketHandler w

Callable<WebSocketSession> connectTask = () -> {
Future<Session> future = this.client.connect(listener, uri, request);
future.get(this.client.getConnectTimeout() + 2000, TimeUnit.MILLISECONDS);
try {
future.get(this.client.getConnectTimeout() + this.client.getHttpClient().getIdleTimeout() + 1000, TimeUnit.MILLISECONDS);
} catch (Exception ex){
future.cancel(true); // This method will stop the running underlying task
throw new HandshakeFailureException("Failed to connect to remote websocket endpoint", ex);
}
return wsSession;
};

Expand Down