diff --git a/lib/src/main/java/ua/naiksoftware/stomp/WebSocketsConnectionProvider.java b/lib/src/main/java/ua/naiksoftware/stomp/WebSocketsConnectionProvider.java index f1ccd12..e8129a6 100644 --- a/lib/src/main/java/ua/naiksoftware/stomp/WebSocketsConnectionProvider.java +++ b/lib/src/main/java/ua/naiksoftware/stomp/WebSocketsConnectionProvider.java @@ -1,5 +1,6 @@ package ua.naiksoftware.stomp; +import android.os.Looper; import android.util.Log; import org.java_websocket.WebSocket; @@ -17,6 +18,9 @@ import java.util.Map; import java.util.TreeMap; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocketFactory; + import rx.Observable; import rx.Subscriber; @@ -112,6 +116,17 @@ public void onError(Exception ex) { } }; + if(mUri.startsWith("wss")) { + try { + SSLContext sc = SSLContext.getInstance("TLS"); + sc.init(null, null, null); + SSLSocketFactory factory = sc.getSocketFactory(); + mWebSocketClient.setSocket(factory.createSocket()); + } catch (Exception e) { + e.printStackTrace(); + } + } + mWebSocketClient.connect(); haveConnection = true; }