From 5881d2df1cca87633c13c931e43d8cfccc5219c2 Mon Sep 17 00:00:00 2001 From: bdaviaud Date: Fri, 9 Mar 2018 11:32:05 +0100 Subject: [PATCH] fix proxy setting not taken into account in ssl mode --- .../websocket/WebSocketClientWrapper.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/pusher/client/connection/websocket/WebSocketClientWrapper.java b/src/main/java/com/pusher/client/connection/websocket/WebSocketClientWrapper.java index 07e5f256..fe1839b0 100644 --- a/src/main/java/com/pusher/client/connection/websocket/WebSocketClientWrapper.java +++ b/src/main/java/com/pusher/client/connection/websocket/WebSocketClientWrapper.java @@ -1,7 +1,9 @@ package com.pusher.client.connection.websocket; import java.io.IOException; +import java.net.InetSocketAddress; import java.net.Proxy; +import java.net.Socket; import java.net.URI; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; @@ -10,6 +12,7 @@ import javax.net.ssl.SSLException; import javax.net.ssl.SSLSocketFactory; +import com.pusher.java_websocket.WebSocket; import com.pusher.java_websocket.client.WebSocketClient; import com.pusher.java_websocket.handshake.ServerHandshake; @@ -37,9 +40,13 @@ public WebSocketClientWrapper(final URI uri, final Proxy proxy, final WebSocketL // certificates final SSLSocketFactory factory = sslContext.getSocketFactory();// (SSLSocketFactory) - // SSLSocketFactory.getDefault(); - - setSocket(factory.createSocket()); + int port = uri.getPort(); + if( port == -1 ) { + port = WebSocket.DEFAULT_WSS_PORT; + } // SSLSocketFactory.getDefault(); + Socket socket = new Socket(proxy); + socket.connect(new InetSocketAddress(uri.getHost(), port)); + setSocket(factory.createSocket(socket, uri.getHost(), port, true)); } catch (final IOException e) { throw new SSLException(e);