Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fixed ssl with proxy
  • Loading branch information
Sam Nelson committed May 7, 2020
commit 6301c821cfdf9e8b8dfd8d720e6a1277d11a7182
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -10,6 +12,8 @@
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLSocketFactory;

import org.java_websocket.WebSocket;
import org.java_websocket.WebSocketImpl;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;

Expand Down Expand Up @@ -37,9 +41,15 @@ public WebSocketClientWrapper(final URI uri, final Proxy proxy, final WebSocketL
// certificates

final SSLSocketFactory factory = sslContext.getSocketFactory();// (SSLSocketFactory)
// SSLSocketFactory.getDefault();
// SSLSocketFactory.getDefault();

setSocket(factory.createSocket());
int port = uri.getPort();
if( port == -1 ) {
port = WebSocketImpl.DEFAULT_WSS_PORT;
}
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);
Expand Down