Skip to content
Open
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package com.pusher.client.connection.websocket;


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

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 Down Expand Up @@ -35,11 +41,18 @@ public WebSocketClientWrapper(final URI uri, final Proxy proxy, final WebSocketL
// is sufficient unless you
// deal with self-signed
// certificates
final SSLSocketFactory factory = sslContext.getSocketFactory();// (SSLSocketFactory)

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

setSocketFactory(factory);
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);
} catch (final NoSuchAlgorithmException e) {
throw new SSLException(e);
} catch (final KeyManagementException e) {
Expand Down