【问题标题】:Quickblox Javascript SDK - Video Calls via Web RTC Are Always RejectedQuickblox Javascript SDK - 通过 Web RTC 的视频通话总是被拒绝
【发布时间】:2017-11-04 14:04:58
【问题描述】:

我正在尝试创建简单的应用程序来测试 Quickblox 的 Web RTC。

这是关于它的:

  1. 我有两个之前创建的 Quickblox 用户
  2. 根据我传入查询参数 (localhost:3001/?user=XYZ) 的用户,应用程序将使用适当的用户凭据登录我(请记住,我只有两个用户)并将其他用户视为对手
  3. 有一个“呼叫”按钮,单击该按钮将启动会话。

登录代码如下:

    function connectToChat(callback) {
        setViewState('initializing');
        QB.createSession(function(err, res) {
          if (err) {
            return console.error('connectToChat', err);
          } else {
            var userParameters
            if (urlParams['user'] == 1) {
              userParameters = user1Parameters;
            } else {
              userParameters = user2Parameters;
            }
            $('#my_id').html(userParameters.userId);
            QB.login(userParameters, function(err, user) {
              if (err) {
                return console.error('QB.login', err);
              } else {
                var userName = urlParams['user'] == 1 ? 'User#1' : 'User#2';
                QB.users.update(userParameters.userId, {
                  'full_name': userName,
                  'tag_list': ROOM_TAG,
                }, function(updateError, updateUser) {
                    $('#current-user').html('Logged in as : ' + userParameters.userId + ' - ' + userName);
                    if(updateError) {
                        console.error('APP [update user] Error:', updateError);
                    } else {
                      QB.chat.connect({
                        jid: QB.chat.helpers.getUserJid(userParameters.userId, APP_ID),
                        password: userParameters.password,
                      }, callback);
                    }
                });
              }
            });
          }
        })
      }

这是我点击“通话”按钮时的代码:

    function makeCall() {
      console.log('[APP EVENT]', 'Calling the current session');

      var mediaParams = {
        audio: false,
        video: {
            deviceId: undefined
        },
        options: {
          muted: true,
          mirror: true
        },
        elemId: 'localVideo'
      };
      setViewState('calling');

      if (urlParams['user'] == 1) {
        var calleesIds = [user2Parameters.userId];
      } else {
        var calleesIds = [user1Parameters.userId];
      }
      var sessionType = QB.webrtc.CallType.VIDEO; // AUDIO is also possible
      console.log('calleesIds::', calleesIds);
      session = QB.webrtc.createNewSession(calleesIds, sessionType);
      console.log('Session is', session);
      session.getUserMedia(mediaParams, function(err, stream) {
        if (err || !stream.getVideoTracks().length) {
          console.error('Failed to get video tracks', err);
          session.stop({});
          setViewState('error');
        } else {
          session.call({}, function(error) {
            if(error) {
              console.warn('session.call', error.detail);
            } else {
              console.log('Called successfully.');
            }
          });
        }
      });
    }

这里是日志:

    [AuthProxy] createSession Object {application_id: "46121", auth_key: "grNjnNAOUDwtC3b", nonce: 1834, timestamp: 1496471781, signature: "c79ba456143ef8dc117516c6c27878e045f1aa26"}
    quickblox.min.js:55221 [ServiceProxy] Request:  POST Object {data: undefined}
    quickblox.min.js:55221 [ServiceProxy] Response:  Object {data: "{"session":{"application_id":46121,"created_at":"2…-06-03T06:36:22Z","user_id":0,"_id":"161537831"}}"}
    quickblox.min.js:55221 [AuthProxy] login Object {userId: 27183475, login: "USERNAME", password: "PASSWORD"}
    quickblox.min.js:55221 [ServiceProxy] Request:  POST Object {data: undefined}
    quickblox.min.js:55221 [ServiceProxy] Response:  Object {data: "{"user":{"id":27183475,"owner_id":54682,"full_name…ter_digits_id":null,"user_tags":"secret-123456"}}"}
    quickblox.min.js:55221 [UsersProxy] update 27183475 Object {full_name: "User#2", tag_list: "secret-123456"}
    quickblox.min.js:55221 [ServiceProxy] Request:  PUT Object {data: undefined}
    quickblox.min.js:55221 [ServiceProxy] Response:  Object {data: "{"user":{"id":27183475,"owner_id":54682,"full_name…ter_digits_id":null,"user_tags":"secret-123456"}}"}
    quickblox.min.js:55221 [ChatProxy] connect Object {jid: "27183475-46121@chat.quickblox.com", password: "PASSWORD"}
    quickblox.min.js:55221 [ChatProxy] Status.CONNECTING
    quickblox.min.js:55221 [ChatProxy] Chat Protocol - WebSocket
    quickblox.min.js:55221 [QBChat] SENT: <open xmlns=​"urn:​ietf:​params:​xml:​ns:​xmpp-framing" to=​"chat.quickblox.com" version=​"1.0">​</open>​
    quickblox.min.js:55221 [QBChat] RECV: <open xmlns=​"urn:​ietf:​params:​xml:​ns:​xmpp-framing" from=​"chat.quickblox.com" id=​"c4f15c35-e9f0-4d12-9430-a327dd72e217" version=​"1.0" xml:lang=​"en">​</open>​
    quickblox.min.js:55221 [QBChat] RECV: <stream:features xmlns:stream=​"http:​/​/​etherx.jabber.org/​streams">​…​</stream:features>​
    quickblox.min.js:55221 [QBChat] SENT: <auth xmlns=​"urn:​ietf:​params:​xml:​ns:​xmpp-sasl" mechanism=​"PLAIN">​…​</auth>​
    quickblox.min.js:55221 [QBChat] RECV: <success xmlns=​"urn:​ietf:​params:​xml:​ns:​xmpp-sasl">​</success>​
    quickblox.min.js:55221 [QBChat] SENT: <open xmlns=​"urn:​ietf:​params:​xml:​ns:​xmpp-framing" to=​"chat.quickblox.com" version=​"1.0">​</open>​
    quickblox.min.js:55221 [QBChat] RECV: <open xmlns=​"urn:​ietf:​params:​xml:​ns:​xmpp-framing" from=​"chat.quickblox.com" id=​"c4f15c35-e9f0-4d12-9430-a327dd72e217" version=​"1.0" xml:lang=​"en">​</open>​
    quickblox.min.js:55221 [QBChat] RECV: <stream:features xmlns:stream=​"http:​/​/​etherx.jabber.org/​streams">​…​</stream:features>​
    quickblox.min.js:55221 [QBChat] SENT: <iq type=​"set" id=​"_bind_auth_2" xmlns=​"jabber:​client">​…​</iq>​
    quickblox.min.js:55221 [QBChat] RECV: <iq xmlns=​"jabber:​client" to=​"27183475-46121@chat.quickblox.com/​1571722472-quickblox-2693571" type=​"result" id=​"_bind_auth_2">​…​</iq>​
    quickblox.min.js:55221 [QBChat] SENT: <iq type=​"set" id=​"_session_auth_2" xmlns=​"jabber:​client">​…​</iq>​
    quickblox.min.js:55221 [QBChat] RECV: <iq xmlns=​"jabber:​client" to=​"27183475-46121@chat.quickblox.com/​1571722472-quickblox-2693571" type=​"result" id=​"_session_auth_2">​</iq>​
    quickblox.min.js:55221 [ChatProxy] Status.CONNECTED at 16:36:27
    quickblox.min.js:55221 [QBChat] SENT: <iq type=​"set" from=​"27183475-46121@chat.quickblox.com/​1571722472-quickblox-2693571" id=​"87836bf7-f1d7-4605-8e86-3298160dd5bb:​enableCarbons" xmlns=​"jabber:​client">​…​</iq>​
    quickblox.min.js:55221 [QBChat] SENT: <presence xmlns=​"jabber:​client">​</presence>​
    quickblox.min.js:55221 [QBChat] SENT: <iq type=​"get" from=​"27183475-46121@chat.quickblox.com/​1571722472-quickblox-2693571" id=​"9c926c20-a437-4a5a-879d-a44616fc8d86:​getRoster" xmlns=​"jabber:​client">​…​</iq>​
    quickblox.min.js:55221 [QBChat] RECV: <iq xmlns=​"jabber:​client" to=​"27183475-46121@chat.quickblox.com/​1571722472-quickblox-2693571" type=​"result" id=​"87836bf7-f1d7-4605-8e86-3298160dd5bb:​enableCarbons">​</iq>​
    quickblox.min.js:55221 [QBChat] RECV: <iq xmlns=​"jabber:​client" to=​"27183475-46121@chat.quickblox.com/​1571722472-quickblox-2693571" type=​"result" id=​"9c926c20-a437-4a5a-879d-a44616fc8d86:​getRoster">​…​</iq>​
    app.js:56 Connected to chat.
    quickblox.min.js:55221 [UsersProxy] get Object {tags: Array(1), per_page: 100}
    quickblox.min.js:55221 [ServiceProxy] Request:  GET Object {data: undefined}
    quickblox.min.js:55221 [QBChat] RECV: <presence xmlns=​"jabber:​client" to=​"27183475-46121@chat.quickblox.com" from=​"27183475-46121@chat.quickblox.com/​1571722472-quickblox-2691871">​</presence>​
    quickblox.min.js:55221 [QBChat] RECV: <presence xmlns=​"jabber:​client" to=​"27183475-46121@chat.quickblox.com" from=​"27183475-46121@chat.quickblox.com/​1571722472-quickblox-2693360">​</presence>​
    quickblox.min.js:55221 [QBChat] RECV: <presence xmlns=​"jabber:​client" to=​"27183475-46121@chat.quickblox.com" from=​"27183475-46121@chat.quickblox.com/​1571722472-quickblox-2693571">​</presence>​
    quickblox.min.js:55221 [ServiceProxy] Response:  Object {data: "{"current_page":1,"per_page":100,"total_entries":2…r_digits_id":null,"user_tags":"secret-123456"}}]}"}
    app.js:166 [APP EVENT] Calling the current session
    app.js:187 calleesIds:: [26345193]
    app.js:189 Session is n {ID: "01b6e562-e1b2-445d-a5fc-4fcf4683d98c", state: 1, initiatorID: 27183475, opponentsIDs: Array(1), callType: 1…}
    quickblox.min.js:52658 [QBWebRTC]: Call, extension: {}
    quickblox.min.js:52658 [QBWebRTC]: _createPeer, iceServers: {"iceServers":[{"url":"stun:stun.l.google.com:19302","urls":"stun:stun.l.google.com:19302"},{"url":"stun:turn.quickblox.com","username":"quickblox","credential":"baccb97ba2d92d71e26eb9886da5f1e0","urls":"stun:turn.quickblox.com"},{"url":"turn:turn.quickblox.com:3478?transport=udp","username":"quickblox","credential":"baccb97ba2d92d71e26eb9886da5f1e0","urls":"turn:turn.quickblox.com:3478?transport=udp"},{"url":"turn:turn.quickblox.com:3478?transport=tcp","username":"quickblox","credential":"baccb97ba2d92d71e26eb9886da5f1e0","urls":"turn:turn.quickblox.com:3478?transport=tcp"},{"url":"turn:turnsingapor.quickblox.com:3478?transport=udp","username":"quickblox","credential":"baccb97ba2d92d71e26eb9886da5f1e0","urls":"turn:turnsingapor.quickblox.com:3478?transport=udp"},{"url":"turn:turnsingapore.quickblox.com:3478?transport=tcp","username":"quickblox","credential":"baccb97ba2d92d71e26eb9886da5f1e0","urls":"turn:turnsingapore.quickblox.com:3478?transport=tcp"},{"url":"turn:turnireland.quickblox.com:3478?transport=udp","username":"quickblox","credential":"baccb97ba2d92d71e26eb9886da5f1e0","urls":"turn:turnireland.quickblox.com:3478?transport=udp"},{"url":"turn:turnireland.quickblox.com:3478?transport=tcp","username":"quickblox","credential":"baccb97ba2d92d71e26eb9886da5f1e0","urls":"turn:turnireland.quickblox.com:3478?transport=tcp"}]}
    quickblox.min.js:52658 [QBWebRTC]: RTCPeerConnection init. userID: 26345193, sessionID: 01b6e562-e1b2-445d-a5fc-4fcf4683d98c, type: offer
    quickblox.min.js:52763 _callInternal
    app.js:200 Called successfully.
    quickblox.min.js:52658 [QBWebRTC]: getAndSetLocalSessionDescription success
    quickblox.min.js:52658 [QBWebRTC]: _startDialingTimer, dialingTimeInterval: 5000
    quickblox.min.js:52658 [QBWebRTC]: _dialingCallback, answerTimeInterval: 0
    quickblox.min.js:55221 [QBChat] SENT: <message to=​"26345193-46121@chat.quickblox.com" type=​"headline" id=​"593258f4858e5a6ec7000000" xmlns=​"jabber:​client">​…​</message>​
    quickblox.min.js:55221 [QBChat] RECV: <message xmlns="jabber:client" to="27183475-46121@chat.quickblox.com" id="593258f53446726f40000025" from="26345193-46121@chat.quickblox.com/1571722472-quickblox-2691870" type="headline"><extraParams xmlns="jabber:client"><callType>1</callType><callerID>27183475</callerID><opponentsIDs><opponentID>26345193</opponentID></opponentsIDs><sessionID>01b6e562-e1b2-445d-a5fc-4fcf4683d98c</sessionID><moduleIdentifier>WebRTCVideoChat</moduleIdentifier><signalType>reject</signalType><platform>web</platform></extraParams></message>
    quickblox.min.js:52658 [QBWebRTC]: onReject. UserID:27183475. SessionID: 01b6e562-e1b2-445d-a5fc-4fcf4683d98c
    app.js:81 onRejectCallListener. The other person rejected the call.
    quickblox.min.js:52664 [QBWebRTC]: Ignore 'OnReject', there is no information about peer connection by some reason.
    traceError @ quickblox.min.js:52664
    n.processOnReject @ quickblox.min.js:52849
    n._onRejectListener @ quickblox.min.js:52621
    _onMessage @ quickblox.min.js:52999
    _onSystemMessageListener @ quickblox.min.js:51072
    run @ quickblox.min.js:37985
    (anonymous) @ quickblox.min.js:38206
    forEachChild @ quickblox.min.js:37758
    _dataRecv @ quickblox.min.js:38201
    _onMessage @ quickblox.min.js:38823
    quickblox.min.js:52658 [QBWebRTC]: All peer connections closed: false
    quickblox.min.js:55221 [QBChat] RECV: <message xmlns=​"jabber:​client" to=​"27183475-46121@chat.quickblox.com" id=​"593258f5b2eadf50f700002a" from=​"27183475-46121@chat.quickblox.com/​1571722472-quickblox-2691871" type=​"headline">​…​</message>​
    quickblox.min.js:52658 [QBWebRTC]: onReject. UserID:27183475. SessionID: 01b6e562-e1b2-445d-a5fc-4fcf4683d98c
    app.js:81 onRejectCallListener. The other person rejected the call.
    quickblox.min.js:52664 [QBWebRTC]: Ignore 'OnReject', there is no information about peer connection by some reason.
    traceError @ quickblox.min.js:52664
    n.processOnReject @ quickblox.min.js:52849
    n._onRejectListener @ quickblox.min.js:52621
    _onMessage @ quickblox.min.js:52999
    _onSystemMessageListener @ quickblox.min.js:51072
    run @ quickblox.min.js:37985
    (anonymous) @ quickblox.min.js:38206
    forEachChild @ quickblox.min.js:37758
    _dataRecv @ quickblox.min.js:38201
    _onMessage @ quickblox.min.js:38823
    quickblox.min.js:52658 [QBWebRTC]: All peer connections closed: false
    quickblox.min.js:55221 [QBChat] RECV: <message xmlns=​"jabber:​client" to=​"27183475-46121@chat.quickblox.com" id=​"593258f53446726f40000025" from=​"26345193-46121@chat.quickblox.com/​1571722472-quickblox-2691870" type=​"headline">​…​</message>​
    quickblox.min.js:52658 [QBWebRTC]: onReject. UserID:26345193. SessionID: 01b6e562-e1b2-445d-a5fc-4fcf4683d98c
    app.js:81 onRejectCallListener. The other person rejected the call.
    quickblox.min.js:52658 [QBWebRTC]: _clearDialingTimer
    quickblox.min.js:52658 [QBWebRTC]: All peer connections closed: true
    app.js:105 onSessionCloseListener:  n {ID: "01b6e562-e1b2-445d-a5fc-4fcf4683d98c", state: 2, initiatorID: 27183475, opponentsIDs: Array(1), callType: 1…}
    quickblox.min.js:52658 [QBWebRTC]: onIceConnectionStateCallback: closed
    app.js:109 All states Object {UNDEFINED: 0, CONNECTING: 1, CONNECTED: 2, FAILED: 3, DISCONNECTED: 4…}
    app.js:110 Connection state is # 5

如您所见,Quickblox 设法调用,因为有这行:app.js:200 调用成功。

对方接到一个电话,那端执行这段代码:

    QB.webrtc.onCallListener = function(receivingSession, extension) {
      console.log('onCallListener. Someone else is calling me.');
      setViewState('receiving-call');
    };

这是另一边的日志:

    onCallListener. Someone else is calling me.
    quickblox.min.js:52658 [QBWebRTC]: _createPeer, iceServers: {"iceServers":[{"url":"stun:stun.l.google.com:19302","urls":"stun:stun.l.google.com:19302"},{"url":"stun:turn.quickblox.com","username":"quickblox","credential":"baccb97ba2d92d71e26eb9886da5f1e0","urls":"stun:turn.quickblox.com"},{"url":"turn:turn.quickblox.com:3478?transport=udp","username":"quickblox","credential":"baccb97ba2d92d71e26eb9886da5f1e0","urls":"turn:turn.quickblox.com:3478?transport=udp"},{"url":"turn:turn.quickblox.com:3478?transport=tcp","username":"quickblox","credential":"baccb97ba2d92d71e26eb9886da5f1e0","urls":"turn:turn.quickblox.com:3478?transport=tcp"},{"url":"turn:turnsingapor.quickblox.com:3478?transport=udp","username":"quickblox","credential":"baccb97ba2d92d71e26eb9886da5f1e0","urls":"turn:turnsingapor.quickblox.com:3478?transport=udp"},{"url":"turn:turnsingapore.quickblox.com:3478?transport=tcp","username":"quickblox","credential":"baccb97ba2d92d71e26eb9886da5f1e0","urls":"turn:turnsingapore.quickblox.com:3478?transport=tcp"},{"url":"turn:turnireland.quickblox.com:3478?transport=udp","user
    name":"quickblox","credential":"baccb97ba2d92d71e26eb9886da5f1e0","urls":"turn:turnireland.quickblox.com:3478?transport=udp"},{"url":"turn:turnireland.quickblox.com:3478?transport=tcp","username":"quickblox","credential":"baccb97ba2d92d71e26eb9886da5f1e0","urls":"turn:turnireland.quickblox.com:3478?transport=tcp"}]}
    quickblox.min.js:52658 [QBWebRTC]: RTCPeerConnection init. userID: 27183475, sessionID: c7bc18fc-746f-445b-b631-40e1cfa6ca85, type: answer
    quickblox.min.js:52658 [QBWebRTC]: _startAnswerTimer
    quickblox.min.js:55219 [QBChat] RECV: <message xmlns=​"jabber:​client" to=​"26345193-46121@chat.quickblox.com/​1571722472-quickblox-2693645" from=​"26345193-46121@chat.quickblox.com" type=​"headline" id=​"5932598f3446726f40000026">​<sent xmlns=​"urn:​xmpp:​carbons:​2">​<forwarded xmlns=​"urn:​xmpp:​forward:​0">​<message xmlns=​"jabber:​client" to=​"27183475-46121@chat.quickblox.com" id=​"5932598f3446726f40000026" from=​"26345193-46121@chat.quickblox.com/​1571722472-quickblox-2691870" type=​"headline">​<extraParams xmlns=​"jabber:​client">​<callType>​1​</callType>​<callerID>​27183475​</callerID>​<opponentsIDs>​<opponentID>​26345193​</opponentID>​</opponentsIDs>​<sessionID>​c7bc18fc-746f-445b-b631-40e1cfa6ca85​</sessionID>​<moduleIdentifier>​WebRTCVideoChat​</moduleIdentifier>​<signalType>​reject​</signalType>​<platform>​web​</platform>​</extraParams>​</message>​</forwarded>​</sent>​</message>​
    quickblox.min.js:52658 [QBWebRTC]: onReject. UserID:26345193. SessionID: c7bc18fc-746f-445b-b631-40e1cfa6ca85
    app.js:80 onRejectCallListener. The other person rejected the call.
    quickblox.min.js:52664 [QBWebRTC]: Ignore 'OnReject', there is no information about peer connection by some reason

如您所见,呼叫之后几乎立即出现拒绝消息。

这几天我一直在尝试解决这个问题,但我还没有找到解决方案。

我还查看了 github 上的示例 webrtc 应用程序,但我没有查明问题出在我的代码中。

【问题讨论】:

    标签: javascript web webrtc quickblox


    【解决方案1】:

    @krunal 如果您在本地(同一台电脑)练习视频通话,那么这可能不起作用, 我遇到了同样的问题,它不允许我接听电话,

    quickblox 在控制台中给出确切的错误,

    [QBWRTC] Can't accept the call, there is no information about peer connection by some reason
    

    用两台不同的电脑试一试,然后打电话, 希望这会有所帮助。

    【讨论】:

    • 谢谢两天前就解决了,谢谢你的回答。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-27
    • 1970-01-01
    • 1970-01-01
    • 2016-09-28
    • 1970-01-01
    相关资源
    最近更新 更多