diff --git a/src/main/java/hudson/remoting/Engine.java b/src/main/java/hudson/remoting/Engine.java index 29d7ae6fc..fc55f2747 100644 --- a/src/main/java/hudson/remoting/Engine.java +++ b/src/main/java/hudson/remoting/Engine.java @@ -625,8 +625,10 @@ public void closeRead() throws IOException { } } } + String wsUrl = candidateUrls.get(0).toString().replaceFirst("^http", "ws"); + if(!wsUrl.endsWith("/")) wsUrl += "/"; ContainerProvider.getWebSocketContainer().connectToServer(new AgentEndpoint(), - ClientEndpointConfig.Builder.create().configurator(headerHandler).build(), URI.create(candidateUrls.get(0).toString().replaceFirst("^http", "ws") + "wsagents/")); + ClientEndpointConfig.Builder.create().configurator(headerHandler).build(), URI.create(wsUrl + "wsagents/")); while (ch.get() == null) { Thread.sleep(100); }