code: protected synchronized void connect()
      {
          if (api.getStatus() != JDA.Status.ATTEMPTING_TO_RECONNECT)
              api.setStatus(JDA.Status.CONNECTING_TO_WEBSOCKET);
          if (shutdown)
              throw new RejectedExecutionException("JDA is shutdown!");
          initiating = true;
  
          String url = api.getGatewayUrl() + "?encoding=json&v=" + DISCORD_GATEWAY_VERSION;
          if (compression)
          {
              url += "&compress=zlib-stream";
              decompressBuffer = newDecompressBuffer();
          }
  
          try
          {
              socket = api.getWebSocketFactory()
                      .createSocket(url)
                      .addHeader("Accept-Encoding", "gzip")
                      .addListener(this);
              socket.connect();
          }
          catch (IOException | WebSocketException e)
          {
              api.resetGatewayUrl();
              //Completely fail here. We couldn't make the connection.
              throw new IllegalStateException(e);
          }
      }
docs: /*
  ### Start Internal methods ###