code: private void reconnect(final ArrayList<Long> tokens) {
          nonUserDisconnect();
          try {
              ws = new WebSocketFactory().createSocket(wsuri);
          } catch (IOException e) {
              if(onErrorListener != null) {
                  onErrorListener.onError(e);
              }
                  return;
          }
          ws.addListener(getWebsocketAdapter());
          connect();
          final OnConnect onUsersConnectedListener = this.onConnectedListener;
          setOnConnectedListener(new OnConnect() {
              @Override
              public void onConnected() {
                  if(subscribedTokens.size() > 0) {
                      //take a backup of mode map as it will be overriden to modeQuote after subscribe
                      Map<Long, String> backupModeMap = new HashMap<>();
                      backupModeMap.putAll(modeMap);
                      ArrayList<Long> tokens = new ArrayList<>();
                      tokens.addAll(subscribedTokens);
                      subscribe(tokens);
  
                      Map<String, ArrayList<Long>> modes = new HashMap<>();
                      for (Map.Entry<Long, String> item: backupModeMap.entrySet()){
                          if(!modes.containsKey(item.getValue())){
                              modes.put(item.getValue(), new ArrayList<Long>());
                          }
                          modes.get(item.getValue()).add(item.getKey());
                      }
                      for(Map.Entry<String, ArrayList<Long>> modeArrayItem: modes.entrySet()){
                          setMode(modeArrayItem.getValue(), modeArrayItem.getKey());
                      }
                  }
                  lastPongAt = 0;
                  count = 0;
                  nextReconnectInterval = 0;
                  onConnectedListener = onUsersConnectedListener;
                  }
              });
      }
docs: Disconnects and reconnects com.zerodhatech.ticker.