Skip to content

Best way to find a free server (from a server pool) #4331

Discussion options

You must be logged in to vote

I think the issue is that the socket reference is updated, but the listeners are still attached to the previous socket instance.

You need to either:

  • move the listeners in the tryConnect() method
const tryConnect = (server: string) => {
  return io(server, {
    autoConnect: true,
    forceNew: true,
    transports: ["websocket"],
    timestampRequests: true,
    reconnection: true,
    reconnectionAttempts: RECON_TRIALS,
    reconnectionDelay: RECON_DELAY,
    reconnectionDelayMax: RECON_MAX,
    rejectUnauthorized: false,
    timeout: TIMEOUT,
    secure: true,
  })
  .on("full", () => {
    console.log("SIO: Server full!");
    socket.disconnect();
    setConnectedStatus(false);
    r…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@HarikalarKutusu
Comment options

Answer selected by HarikalarKutusu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants