code: SocketInterface createSocket(@NonNull final String token, @NonNull final WeakReference<SocketStateListener> stateListenerWeakReference) {
  
          WebSocket socket = null;
  
          WebSocketFactory factory = new WebSocketFactory();
  
          // Configure proxy if provided
          if (proxyAddress != null) {
              ProxySettings settings = factory.getProxySettings();
              settings.setServer(proxyAddress);
          }
  
          try {
              socket = factory.createSocket(uri, TIMEOUT);
          } catch (IOException e) {
              log.f("Creating socket failed", e);
          }
  
          if (socket != null) {
  
              String header = AuthManager.AUTH_PREFIX + token;
              socket.addHeader("Authorization", header);
  
              socket.addListener(createWebSocketAdapter(stateListenerWeakReference));
  
              socket.setPingInterval(PING_INTERVAL);
  
              return new SocketWrapperImpl(socket);
          }
  
          return null;
      }
docs: Creates and configures web socket instance.
  
  @param token                      Authentication token.
  @param stateListenerWeakReference Weak reference to socket connection state callbacks.