Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reconnect() doesn't work #256

Open
thomaskahabka opened this issue Sep 13, 2021 · 4 comments
Open

reconnect() doesn't work #256

thomaskahabka opened this issue Sep 13, 2021 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@thomaskahabka
Copy link

Versions
Please fill in all that apply:

  • Convergence Version: 1.0.0.rc12
  • OS: any
  • Browser: Chrome

Describe the Bug
Convergence.reconnect(url,reconnectToken) never returns either a domain nor an error.

Step To Reproduce
A code snippet or gist to reproduce the issue will greatly improve our response time
please see: https://github.com/thomaskahabka/convergence_test for a vuejs test application.

Expected Behavior
reconnect() to return a domain, as was working in rc7

@thomaskahabka thomaskahabka added the bug Something isn't working label Sep 13, 2021
@mmacfadden
Copy link
Contributor

Hello thanks for reporting. We will see if we can replicate and report back.

@thomaskahabka
Copy link
Author

Thank you for looking into this.
We stopped using reconnect() now and switched to re-validating via JWT - which actually is much safer anyway.

@earshinov
Copy link

earshinov commented Nov 15, 2021

Here is what we are going to use:

import * as Convergence from '@convergence/convergence';

function patchReconnect(domain: Convergence.ConvergenceDomain) {
  // Patch Convergence Connection class to reconnect with the original JWT instead of a reconnect token.
  // Reconnecting with a reconnect token appears to be broken atm:
  // https://github.com/convergencelabs/convergence-project/issues/256
  const connection = (domain as any)._connection;
  connection.connectWithReconnectToken = connectWithReconnectToken;
}

function connectWithReconnectToken(this: any /* ConvergenceConnection */): Promise<void> {
  const gen = this._connectionRequestGenerator;
  return (gen
    ? this._connect(gen).catch((e: any) => this._handleReconnectFailure(e))
    : Promise.reject(new Error('No connectionRequestGenerator!  Have you connected even once before calling reconnect()?'))
  );
}

This function is called like this:

Convergence.connectWithJwt(url, jwt, {...}).then(domain => {
  patchReconnect(domain);
  ... 
});   

@mmacfadden mmacfadden self-assigned this Feb 9, 2022
@thomaskahabka
Copy link
Author

Thank you - works like a charm, as long as the JWT token is still valid. Is there a chance to get a hook to refresh the JWT token while convergence tries to reconnect ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants