2

I am trying to create simple app to test Quickblox's Web RTC.

Here is what it is about:

  1. I have two Quickblox users that I created earlier
  2. Depending on which user I pass in query parameters (localhost:3001/?user=XYZ), the app will log me in using the appropriate user credentials (Remember, I only have two users) and treat the other user as an opponent
  3. There is a button to "Call", clicking which will initiate a session.

Here is the code for logging in:

    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);
                    }
                });
              }
            });
          }
        })
      }

Here is the code when I click on "call" button:

    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.');
            }
          });
        }
      });
    }

Here are the logs:

    [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

As you can see, Quickblox manages to call since there is this line: app.js:200 Called successfully.

The other side receives a call, and this code is executed on that end:

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

Here are the logs from the other side:

    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

As you can see, the call is almost immediately followed by a reject message.

I have been trying to figure this out for a few days, and I haven't found a solution yet.

I have also looked at the sample webrtc app on github, but I haven't pinpointed where the problem is in my code.

ruffin
  • 16,507
  • 9
  • 88
  • 138
user1076731
  • 203
  • 3
  • 14

1 Answers1

0

@krunal If You Are practising video call in Local(Same PC) then this might not work, I had the same issue where it wont allow me to accept the call,

quickblox gives the exact error in console,

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

Try it with two different PC and call, hope this helps.

Gaurang Sondagar
  • 311
  • 2
  • 11