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

"punycode.ucs2.decode undefined" when ever _resumeConnection() is called. #2109

Open
kaushikRitik opened this issue Sep 13, 2022 · 6 comments

Comments

@kaushikRitik
Copy link

kaushikRitik commented Sep 13, 2022

Description

const url = new URL(this._stropheConn.service);

The app crashes whenever the internet connection is interrupted because of URL class of javascript.

Possible Solution

We were able to fix it by bypassing the code.

Steps to reproduce

  • Step-1 Use the bundled lib-jitsi-meet
  • Step-2 Bundle your javascript code
  • Step-3 Use the bundled code in your react-native
  • Step-4 When on call just turn off the wifi the app will crash.

Environment details

React-Native (all latest versions)

@saghul
Copy link
Member

saghul commented Sep 13, 2022

What BOSH URL are you using?

@kaushikRitik
Copy link
Author

this is the option we are passing in the makeConnection
{ hosts: { domain: domain, muc: "conference." + domain, focus: "focus." + domain, }, serviceUrl: "wss://xmpp." + domain + "/xmpp-websocket", bosh: "https://xmpp." + domain + "/http-bind", }

@saghul
Copy link
Member

saghul commented Sep 14, 2022

What is your domain?

@kaushikRitik
Copy link
Author

kaushikRitik commented Sep 16, 2022

domain is "test.ritik.io"

@saghul
Copy link
Member

saghul commented Sep 16, 2022

Since you are using LJM directly, are you polyfilling URL? We use https://github.com/charpeni/react-native-url-polyfill without problems.

@kaushikRitik
Copy link
Author

kaushikRitik commented Sep 19, 2022

We are also using the polyfills like used in jitsi meet but we still got the error.

Here is the fix if anyone else got this error.

 _resumeConnection() {
    const { streamManagement } = this._stropheConn;
    const resumeToken = streamManagement.getResumeToken();

    // Things may have changed since when the task was scheduled
    if (!resumeToken) {
        return;
    }

    logger.info('Trying to resume the XMPP connection');
    let url = this._stropheConn.service;
    let search = url.includes("?") ? url.replace(/.*\?/, "?") : "";
    const pattern = /(previd=)([\w-]+)/;
    const oldToken = search.match(pattern);

    // Replace previd if the previd value has changed.
    if (oldToken && oldToken.indexOf(resumeToken) === -1) {
        search = search.replace(pattern, `$1${resumeToken}`);

    // Append previd if it doesn't exist.
    } else if (!oldToken) {
        search += search.indexOf('?') === -1 ? `?previd=${resumeToken}` : `&previd=${resumeToken}`;
    }
    url = url.includes("?") ? url.replace(/\?.*/, search) : url + search;
    this._stropheConn.service = url.toString();

    streamManagement.resume();
}

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants