code: private void reconnect(WebSocketChannel channel, WSURI uri, String protocol) {
          LOG.entering(CLASS_NAME, "reconnect", new Object[] { uri, protocol });
  
          WebSocketNativeChannel wsChannel = (WebSocketNativeChannel)channel;
          wsChannel.redirectUri = uri;
          
          WebSocketCompositeChannel compChannel = (WebSocketCompositeChannel)channel.getParent();
          HttpRedirectPolicy option = compChannel.getFollowRedirect();
          URI currentURI = channel.getLocation().getURI();
          URI redirectURI = uri.getURI();
          
          // option will be null only for unit tests.
          if ((option != null) && (option.compare(currentURI, redirectURI) != 0)) {
              String s = String.format("%s: Cannot redirect from '%s' to '%s'",
                                       option, currentURI, redirectURI);
              channel.preventFallback = true;
              throw new IllegalStateException(s);
          }
          
          wsChannel.reconnecting.compareAndSet(false, true);
      }
docs: Connect to the WebSocket
  
  @throws Exception