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

Avoid indefinite wait to connect in JettyWebSocketClient #23994

Closed
wants to merge 1 commit into from
Closed

Avoid indefinite wait to connect in JettyWebSocketClient #23994

wants to merge 1 commit into from

Commits on Nov 14, 2019

  1. Set a timeout in Future<Session>

    In some cases, org.eclipse.jetty.websocket.client.WebSocketClient.connect(listener, uri, request) call will return a future that never is completed. It is reasonable that our future.get() must have a timeout to avoid thread blocking.
    I suggest something like:
    		Callable<WebSocketSession> connectTask = () -> {
    			Future<Session> future = this.client.connect(listener, uri, request);
                            try {
    				// TODO Configurable timeout
    				future.get(2000, TimeUnit.MILLISECONDS);
                            } catch (Exception ex){
                                     logger.error("Failed to connect to remote websocket endpoint", ex);
                                     future.cancel(true); // This method will stop the running underlying task
                            }
    			return wsSession;
    		};
    Kukosoft committed Nov 14, 2019
    Copy the full SHA
    b5326c1 View commit details
    Browse the repository at this point in the history