Closed meosieudang closed 2 years ago
i have 4 user A, B, C, D The bug appears when A call to B,C,D then B and C and D accept and then B or C or D will error [VideoChat]: 'setRemoteSessionDescription' error: [object Object] => lost connect stream
@meosieudang Could you share a code where you receive a call and do accept on the call? Did you check our VideoChat sample?
FYI - How we do accept a call
here is press accept button:
_onPressAccept = (notification) => { CallService.acceptCall(this._session) .then((stream) => { const { opponentsIDs, initiatorID, currentUserID } = this._session const opponentsIds = [initiatorID, ...opponentsIDs].filter( (userId) => currentUserID !== userId ) this.initRemoteStreams(opponentsIds) this._setLocalStream([{ userId: 'localStream', stream }]) this.setInfoCalling( notification.hasVideo, notification.roomId, notification.callerName, opponentsIds, notification.isGroupChat ) this.hideIncomingCall() }) .catch((e) => { showToast('Có lỗi trong quá trình kết nối, vui lòng thử lại sau.') CallService.stopCall() this.resetState() }) }
@ccvlad , here is func acceptCall
acceptCall = (session) => { this.stopSounds(); this._session = session; this.setMediaDevices();
return this._session
.getUserMedia(CallService.MEDIA_OPTIONS)
.then((stream) => {
this._session.accept({});
return stream;
});
};
@ccvlad , https://www.youtube.com/watch?v=e4q9dQXkIEw please see the movie to see error
Could you test a call on real devices? I'm not sure that WebRTC will work correctly on the simulator
@ccvlad , sir i'm try test it on 4 real devices and sometime will lost 1 stream in 4 devices :((
I need some time to check you logs from video. Can I reproduce the issue on our VideoChat sample or it just related to your code?
@meosieudang
Seems you call a session.accept()
more than once. Check this please. You should call the session.accept()
after getting the session in ConnectyCube.videochat.onCallListener = (session, extension) => {/* accept/reject */}
@ccvlad , the func accept call i just call once, sir. The bug appears
A => B and C
B will receive event _onAcceptCallListener and _onRemoteStreamListener from A, and C
C will receive event _onAcceptCallListener and _onRemoteStreamListener from A, and B
A => receive stream from B and C 👍
B => receive stream A 👍 but stream C sometime happen error setRemoteSessionDescription
C => receive stream A 👍 but stream B sometime happen error setRemoteSessionDescription
Can I reproduce the issue on our VideoChat sample or it just related to your code?
?
@ccvlad, yes you can reproduce the issue on your example but sometime happen like my code
I have tested our samples but can't reproduce the same error. I quickly pressed the 'Accept' button twice, but have gotten other errors. Could you attach logs with the error in this thread?
Sir, the issue happen A call to B and C. When B and C receive event onCallListener show modal acept and reject button. You need to press the accept button at B and C at the same time to get the error Vào Th 3, 2 thg 2, 2021 lúc 18:58 ccvlad notifications@github.com đã viết:
I have tested our samples but can't reproduce the same error. I quickly pressed the 'Accept' button twice, but have gotten other errors. Could you attach logs with the error in this thread?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ConnectyCube/connectycube-reactnative-samples/issues/204#issuecomment-771585928, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK6JCD57IUM3BGQIVZC46LLS47SHDANCNFSM4W6FWEDA .
Try to debug w/o Google Chrome console, use only Metro server. Will the error appear?
Im try turn off debug but still this error. The issue happen when my app build on testflight appstore connect. Someone user in group chat will state freeze face and disconnect. Then i try init new video call group and never fire event onRemoteStreamListener
Vào Th 3, 2 thg 2, 2021 lúc 20:03 ccvlad notifications@github.com đã viết:
Try to debug w/o Google Chrome console, use only Metro server. Will the error appear?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ConnectyCube/connectycube-reactnative-samples/issues/204#issuecomment-771619757, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK6JCDZI3MSTG5DTSODWI2TS47Z2ZANCNFSM4W6FWEDA .
Try to debug w/o Google Chrome console, use only Metro server. Will the error appear?
Please send. I will check the sequence
@ccvlad ,
user A has id 3101422 (initiator call)
user B has id 3050168
user C has id 3082051
you can see event _onAcceptCallListener call 2 times on user C => issue setRemoteSessionDescription p/s: i'm just press accept call once
@ccvlad , this issue from cubeWebRTCSession.js file
_processOnAccept(userID, extension) { const peerConnection = this.peerConnections[userID]; if (peerConnection) { peerConnection._clearDialingTimer(); peerConnection .setRemoteSessionDescription('answer', extension.sdp) .then(() => { Helpers.trace("'setRemoteSessionDescription' success"); }) .catch(error => { console.warn(error); Helpers.traceError("'setRemoteSessionDescription' error: " + error); }); } else { Helpers.traceWarning("Ignore 'OnAccept', there is no information about peer connection by some reason."); } }
the issue appear on sample code @ccvlad
Hi @meosieudang
I've found the error!
100% to reproduce the case:
FYI. Our sample has 4 hardcoded user (Alice, Bob, Ciri and Dexter). So, somebody else is able to use the RNVideoChat when you are testing too.
To avoid the error use the code snippet below:
ConnectyCube.videochat.onCallListener = (session, extension) => {
// show the incoming call screen/modal with abilities to accept and reject
}
ConnectyCube.videochat.onAcceptCallListener = (session, userId, extension) => {
// ignore session.accept() from the same user on other device
if (userId === currentUserId) {
// hide the incoming call screen/modal and ignore the call
}
}
@ccvlad , this issue from cubeWebRTCSession.js file
_processOnAccept(userID, extension) { const peerConnection = this.peerConnections[userID]; if (peerConnection) { peerConnection._clearDialingTimer(); peerConnection .setRemoteSessionDescription('answer', extension.sdp) .then(() => { Helpers.trace("'setRemoteSessionDescription' success"); }) .catch(error => { console.warn(error); Helpers.traceError("'setRemoteSessionDescription' error: " + error); }); } else { Helpers.traceWarning("Ignore 'OnAccept', there is no information about peer connection by some reason."); } }
Hi @ccvlad , Can you login an account on a device? the issue happen on above file For the your solution i just handle same userId ago please help me fix this issue
The issue happens after rtcPeerConnection.setRemoteDescription('answer', sdp)
.
The code obtain the peerConnection with user by userId (const peerConnection = this.peerConnections[userID]
) and trying to set SDP (Session Description Protocol) for 'answer', but the peerConnection
already has remote description.
The way to prevent the error is avoid the onAcceptListener
from firing twice from the same user. The first user who accepts the call shouldn't accepts from other device (for the same user logged in on different devices).
You can check:
ConnectyCube.videochat.onAcceptListener = (session, userId, extension) => {
// the same ids will be showe twice before the 'serRemoteSessionDescription' error
console.log(`${userId} accepted the call to ${currentUserId}`)
}
We can prevent the error in our SDK, but it will take some time to release.
Hi @ccvlad , I fixed the problem by checking if the user is setRemoteStream or not on func _processOnAccept So hope you fix it and release next version for lib. thanks
@ccvlad, can i fork lib react-native-connectycube?
@ccvlad , you need check it this code : accept(extension) { const ext = _prepareExtension(extension)
Helpers.trace('Accept, extension: ' + JSON.stringify(ext.userInfo))
if (this.state === SessionState.ACTIVE) {
Helpers.traceError("Can't accept, the session is already active, return.")
return
}
if (this.state === SessionState.CLOSED) {
Helpers.traceError("Can't accept, the session is already closed, return.")
this.stop({})
return
}
this.state = SessionState.ACTIVE
this.acceptCallTime = new Date()
this._clearAnswerTimer()
this._acceptInternal(this.initiatorID, ext)
//group call
const oppIDs = this._uniqueOpponentsIDsWithoutInitiator()
if (oppIDs.length > 0) {
const offerTime = (this.acceptCallTime - this.startCallTime) / 1000
this._startWaitingOfferOrAnswerTimer(offerTime)
oppIDs.forEach((opID) => {
if (this.currentUserID > opID) {
this._callInternal(opID, {}, true)
}
})
}
}
@ccvlad , after //group call i think the problem here
Hi @ccvlad , I fixed the problem by checking if the user is setRemoteStream or not on func _processOnAccept So hope you fix it and release next version for lib. thanks
Great!
@ccvlad, can i fork lib react-native-connectycube?
Unfortunately, the ConnectyCube SDKs stored in private repository. You can install it via NPM, change what you want and use npm pack
to make a TGZ file. Then connect the source from the TGZ file in your package.json:
...
"react-native-connectycube": "file:<path-to-sdk>/react-native-connectycube-<version>.tgz",
...
@ccvlad, here is file i'm fix bug accept call twice cubeWebRTCSession.js.zip
Closed due to inactivity. Please create a new issue if needed.