Failed to load Jitsi Meet API - Error in lib-jitsi-meet during initJitsiConference (TypeError: Cannot read property 'substr')

Hello friends,

I’m trying to use the Jitsi Meet API to create Jitsi Meet video conferences with custom GUI.

I’m receiving a Uncaught TypeError: Cannot read property 'substr' of null when calling initJitsiConference().
I get the following error message:

Uncaught TypeError: Cannot read property 'substr' of null - JitsiConference.js:276
    at se.resourceCreator (JitsiConference.js:276)
    at A.createRoom (xmpp.js:475)
    at se._init (JitsiConference.js:310)
    at new se (JitsiConference.js:130)
    at c.initJitsiConference (JitsiConnection.js:113)

Looking at JitsiConference.js:276 i see this:

JitsiConference.resourceCreator = function(jid, isAuthenticatedUser) {
    let mucNickname;

    if (isAuthenticatedUser) {
        // For authenticated users generate a random ID.
        mucNickname = RandomUtil.randomHexString(8).toLowerCase();
    } else {
        // We try to use the first part of the node (which for anonymous users
        // on prosody is a UUID) to match the previous behavior (and maybe make
        // debugging easier).
        mucNickname = Strophe.getNodeFromJid(jid).substr(0, 8) //LINE 276
            .toLowerCase();

        // But if this doesn't have the required format we just generate a new
        // random nickname.
        const re = /[0-9a-f]{8}/g;

        if (!re.test(mucNickname)) {
            mucNickname = RandomUtil.randomHexString(8).toLowerCase();
        }
    }

    return mucNickname;
};

My script looks like this:

<script src="https://meet.jit.si/libs/lib-jitsi-meet.min.js"></script>
<script type="text/javascript">
JitsiMeetJS.init();

const options = {
	serviceUrl:'https://meet.jit.si/http-bind',
	hosts: {
		domain: 'meet.jit.si',
		muc: 'conference.meet.jit.si',
	},
	bosh: 'https://meet.jit.si/http-bind',
	useStunTurn: true
}

var connection = new JitsiMeetJS.JitsiConnection(null, null, options);

const confOptions = {
	openBridgeChannel: true
}

room = connection.initJitsiConference("testconference1", confOptions);
</script>

Thanks in advance for any help!

Complementing the topic…
Log file (Jicofo.log) I found [WARNING] and [SEVERE]

Jicofo 2020-05-15 20:05:23.771 WARNING: [22] org.jitsi.jicofo.FocusManager.log() No dedicated JVB MUC XMPP connection configured - falling back to the default XMPP connection
...
Jicofo 2020-05-15 20:05:24.335 SEVERE: [28] org.jitsi.impl.protocol.xmpp.OpSetSimpleCapsImpl.getFeatures().144 Failed to discover features for speakerstats.meet.myserver.com: XMPP error reply received from speakerstats.meet.myserver.com: XMPPError: service-unavailable - cancel
Jicofo 2020-05-15 20:05:24.337 SEVERE: [28] org.jitsi.impl.protocol.xmpp.OpSetSimpleCapsImpl.getFeatures().144 Failed to discover features for focus.meet.myserver.com: XMPP error reply received from focus.meet.myserver.com: XMPPError: service-unavailable - wait
Jicofo 2020-05-15 20:05:24.345 SEVERE: [28] org.jitsi.impl.protocol.xmpp.OpSetSimpleCapsImpl.getFeatures().144 Failed to discover features for conferenceduration.meet.myserver.com: XMPP error reply received from conferenceduration.meet.myserver.com: XMPPError: service-unavailable - cancel
...
Jicofo 2020-05-15 20:05:29.629 WARNING: [40] org.jitsi.jicofo.bridge.BridgeSelector.log() No pub-sub node mapped for jvbbrewery@internal.auth.meet.myserver.com/2671872e-fccb-49e9-866b-28813c831825
...
Jicofo 2020-05-15 20:05:29.651 INFO: [55] org.jitsi.jicofo.bridge.JvbDoctor.log() Scheduled health-check task for: jvbbrewery@internal.auth.meet.myserver.com/2671872e-fccb-49e9-866b-28813c831825
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.dom4j.io.SAXContentHandler (file:/usr/share/jicofo/lib/dom4j-1.6.1.jar) to method com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser$LocatorProxy.getEncoding()
WARNING: Please consider reporting this to the maintainers of org.dom4j.io.SAXContentHandler
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

Log file (jvb.log) I found [WARNING]

2020-05-15 20:05:24.645 WARNING: [22] Videobridge.start#906: No authorized source regexp configured. Will accept requests from any source.

I tried with other public instances:

  • meet.jit.si
  • jitsi2.linux.it
  • jitsi-1.belnet.be
  • jitsi.riot.im
  • de-bra-1.jitsi.rocks
  • meet.xrv.pt

And got similar errors:

What should I be doing wrong? @Woodworker_Life can you help me?

You need add:

<script src="https://cdn.jsdelivr.net/npm/strophe.js/dist/strophe.js"></script>
<script src="https://cdn.jsdelivr.net/npm/strophejs-plugin-disco/lib/strophe.disco.js?v=1"></script>
1 Like

What is the jid that is passed to that function?

1 Like

Analyzing more carefully, I concluded that I was not waiting (addEventListener) for the CONNECTION_ESTABLISHED event and with some modifications to the code…

I also removed the option bosh: 'https://meet.jit.si/http-bind', as it looks obsolete. (As contributed by @eduardoflorence).

I included the dependencies of the javascritps: (As contributed by @eduardoflorence).

<script src="https://cdn.jsdelivr.net/npm/strophe.js"></script>
<script src="https://cdn.jsdelivr.net/npm/strophejs-plugin-disco/lib/strophe.disco.js?v=1"></script>

Code with the modifications:

<script src="vendor/jquery/jquery-3.4.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/strophe.js"></script>
<script src="https://cdn.jsdelivr.net/npm/strophejs-plugin-disco/lib/strophe.disco.js?v=1"></script>
<script src="https://meet.jit.si/libs/lib-jitsi-meet.min.js"></script>
<script>

function onConnectionSuccess(){
	const confOptions = {
		openBridgeChannel: true
	}
	room = connection.initJitsiConference("abcdef", confOptions);
	room.join();
	room.myUserId();
	console.log('CONNECTION_ESTABLISHED');
}

JitsiMeetJS.init();

JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.ERROR);

const options = {
	serviceUrl:'https://meet.jit.si/http-bind',
	hosts: {
		domain: 'meet.jit.si',
		muc: 'conference.meet.jit.si',
	}
}

var connection = new JitsiMeetJS.JitsiConnection(null, null, options);

connection.addEventListener(JitsiMeetJS.events.connection.CONNECTION_ESTABLISHED, onConnectionSuccess);

connection.connect();

</script>

See that in the API documentation in item 4 of “Getting started”, the explanation is to wait for the CONNECTION_ESTABLISHED event and only then create the JitsiConference object.
Now it looks like everything is working properly.

Thank you all for your time and dedication, especially @eduardoflorence and @damencho.

I believe I was able to identify my mistake, i was not waiting (addEventListener) for the CONNECTION_ESTABLISHED event and.
I really appreciate your dedication to helping. I hope to be able to repay one day.