Javascript 未能加载Jitsi Meet API-在初始化JITSIConference期间库Jitsi Meet中出错(TypeError:无法读取属性‘;substr’;)

Javascript 未能加载Jitsi Meet API-在初始化JITSIConference期间库Jitsi Meet中出错(TypeError:无法读取属性‘;substr’;),javascript,jitsi,jitsi-meet,Javascript,Jitsi,Jitsi Meet,我正在尝试使用Jitsi Meet API创建带有自定义GUI的Jitsi Meet视频会议 调用initJitsiConference()时,我收到一个Uncaught类型错误:无法读取null的属性'substr' 系统环境的特征: Uncaught TypeError: Cannot read property 'substr' of null - JitsiConference.js:276 at se.resourceCreator (JitsiConference.js:27

我正在尝试使用Jitsi Meet API创建带有自定义GUI的Jitsi Meet视频会议

调用
initJitsiConference()
时,我收到一个
Uncaught类型错误:无法读取null的属性'substr'

系统环境的特征:

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)
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) //// 276 LINE ////
            .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;
};
<script src="vendor/jquery/jquery-3.4.1.min.js"></script>
<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>
Uncaught TypeError: Cannot read property 'substr' of null - JitsiConference.js:263 
    at oe.resourceCreator (JitsiConference.js:263)
    at t.value (xmpp.js:461)
    at oe._init (JitsiConference.js:297)
    at new oe (JitsiConference.js:127)
    at c.initJitsiConference (JitsiConnection.js:113)
<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>
  • 默认的Jitsi METE安装尚未更改
  • 我没有 安装/配置Prosody JWT令牌认证插件
  • 我是 在一个域上运行test.html应用程序,例如: 和Jitsi在其他域上相遇,例如:
我收到以下错误消息(控制台浏览器):

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)
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) //// 276 LINE ////
            .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;
};
<script src="vendor/jquery/jquery-3.4.1.min.js"></script>
<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>
Uncaught TypeError: Cannot read property 'substr' of null - JitsiConference.js:263 
    at oe.resourceCreator (JitsiConference.js:263)
    at t.value (xmpp.js:461)
    at oe._init (JitsiConference.js:297)
    at new oe (JitsiConference.js:127)
    at c.initJitsiConference (JitsiConnection.js:113)
<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>
查看第276行的JitsiConference.js,我看到这样一条信息:

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)
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) //// 276 LINE ////
            .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;
};
<script src="vendor/jquery/jquery-3.4.1.min.js"></script>
<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>
Uncaught TypeError: Cannot read property 'substr' of null - JitsiConference.js:263 
    at oe.resourceCreator (JitsiConference.js:263)
    at t.value (xmpp.js:461)
    at oe._init (JitsiConference.js:297)
    at new oe (JitsiConference.js:127)
    at c.initJitsiConference (JitsiConnection.js:113)
<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>
我的API javascript(mydomain.com/test.html)如下所示:

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)
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) //// 276 LINE ////
            .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;
};
<script src="vendor/jquery/jquery-3.4.1.min.js"></script>
<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>
Uncaught TypeError: Cannot read property 'substr' of null - JitsiConference.js:263 
    at oe.resourceCreator (JitsiConference.js:263)
    at t.value (xmpp.js:461)
    at oe._init (JitsiConference.js:297)
    at new oe (JitsiConference.js:127)
    at c.initJitsiConference (JitsiConnection.js:113)
<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>
我找到的日志文件(Jicofo.Log)有[警告]和[严重]

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
2020-05-15 20:05:24.645 WARNING: [22] Videobridge.start#906: No authorized source regexp configured. Will accept requests from any source.
我找到的日志文件(jvb.Log)[警告]

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
2020-05-15 20:05:24.645 WARNING: [22] Videobridge.start#906: No authorized source regexp configured. Will accept requests from any source.
我应该犯什么错误

提前感谢您的帮助


*对不起,我的英语很弱。

仔细分析后,我得出结论,我没有等待(
addEventListener
)建立连接的事件,并且对代码进行了一些修改

我还删除了选项
bosh:'https://meet.jit.si/http-bind“
,因为它看起来过时了

我包括了JavaScriptps的依赖项:

<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>

修改后的代码:

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)
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) //// 276 LINE ////
            .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;
};
<script src="vendor/jquery/jquery-3.4.1.min.js"></script>
<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>
Uncaught TypeError: Cannot read property 'substr' of null - JitsiConference.js:263 
    at oe.resourceCreator (JitsiConference.js:263)
    at t.value (xmpp.js:461)
    at oe._init (JitsiConference.js:297)
    at new oe (JitsiConference.js:127)
    at c.initJitsiConference (JitsiConnection.js:113)
<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>

函数onConnectionSuccess(){
常数混淆={
openBridgeChannel:正确
}
房间=连接。初始JITSIConference(“abcdef”,共选项);
房间。连接();
room.myUserId();
console.log(“已建立连接”);
}
JitsiMeetJS.init();
setLogLevel(JitsiMeetJS.logLevels.ERROR);
常量选项={
服务URL:'https://meet.jit.si/http-bind',
主持人:{
域:“meet.jit.si”,
muc:“会议。会面。准时。si”
}
}
var connection=new-JitsiMeetJS.JitsiConnection(null,null,options);
connection.addEventListener(JitsiMeetJS.events.connection.connection_已建立,onConnectionSuccess);
connection.connect();
请参见,在中,说明是等待CONNECTION_已建立事件,然后才创建JitsiconReference对象。 现在看来一切正常

感谢大家的时间和奉献精神

注:我是StackOverflow的新手,我正在尽我最大的努力给出能帮助社区的最佳答案