我正在尝试创建一个简单的应用来测试Quickblox的Web RTC。
以下是它的内容:
以下是登录的代码:
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应用程序,但我没有确定代码中的问题所在。
答案 0 :(得分:0)
@krunal如果您正在本地(相同的PC)练习视频通话,那么这可能不起作用, 我有同样的问题,它不允许我接受电话,
quickblox在控制台中提供了确切的错误,
[QBWRTC] Can't accept the call, there is no information about peer connection by some reason
尝试使用两台不同的PC并拨打电话, 希望这有帮助。