Open nuynait opened 2 years ago
Hi @nuynait,
Thanks for opening this issue with us.
Could you please provide a link of your deployed app so I could investigate further? Also, could you please provide a room sid in which this occurs so I can review logs from my end as well?
One thing I noticed is between your last note and it's relation to a group room. It seems to be expected behavior. For example, if your server loses network connection, then your participants will no longer be able to connect. In the case with peer-to-peer, which participant is hosting the node server in your example?
Best, Joyce
@PikaJoyce I’m working with @nuynait on this. Am I understanding you correctly that if the host of a group room loses network, the room is wholly disconnected?
Hi @halostatue
I'm sorry, I meant the computer running the node server. For example in the steps to reproduce, if person B was the computer also running the node server, and person B disconnected from a network.
Hi @PikaJoyce
First, in our deployed version, any participant lost its connection will cause the other participant to disconnect from the room for peer-to-peer type room only.
In the one more thing, I was trying to reproduce on localhost, because debugging on the deployed server directly is hard. So I'm trying to reproduce this issue on localhost. I want to show everything I know in the issue, so I included what I find when I test on localhost at the end of my notes.
On that last note, the server we are using is the front-end react server and a back-end node server. At the point when I disconnect the network, the app is already in the video call and have the room connected. My understanding is that it's interacting with the Twilio server now. The disconnect from its front-end React server and our back-end node server should not cause the Twilio call to be disconnected.
The proof is if you see the last part I mentioned,(on localhost) if I have person A and B connecting to our server from two other computers, then if I disconnect the server network, person A and B can continue doing video calls without issue.
If I have person A and server running on the same computer, then person B on the other, disconnect person A in my opinion should not kick out person B. The actual case is it also disconnect person B in a peer-to-peer type room. However, this exact same experience will not happen in a group-type room. In the group-type room, it will still keep person B connected in the room.
For providing a link to the deployed app, I'm not sure if I can provide that right now. Will need to discuss that with the team.
For room sid, any peer-to-peer type room will have this issue. If you want I can tomorrow, create a peer-to-peer call and make this happen then send you the room sid.
Thank you very much for your time and help Joyce.
I'm sorry that you might feel confused when reading some parts of my notes. I'm not a very good writer. Apologize again if I'm causing you troubles here. Please feel free to let me know any time if there's anything in my writing you have questions about.
Best wishes, Jerry Shan
Hi Jerry,
Thank you for clarifying and please don't apologize! So, I've tried this across several of our own applications such as the react app and our own testing application, all of which are deployed but I unfortunately haven't been able to reproduce it.
Since I'm unable to reproduce it, I'm thinking it may have something to do with this portion :
const disconnect = () => newRoom.disconnect()
newRoom.once('disconnected', () => {
setTimeout(() => setRoom(null))
window.removeEventListener('beforeunload', disconnect)
isMobile && window.removeEventListener('pagehide', disconnect)
})
I want to dig a little bit deeper into this portion here. To me, this reads that when there is a disconnected
event. You call disconnect
. But every participant runs this? Please correct me if I'm wrong here.
I only noticed this because we are also not handling any participant disconnected events which might be what you need here. Cleaning up once a participant has left the room versus cleaning up when a room disconnects.
Here's some extra documentation, here's another one but it's for reconnection states rather than disconnected.
You can alternatively try using room.on('participantDisconnected', ...)
as well.
Again, please correct me if I'm wrong. But regardless I hope this helps and if none of my suggestions are working, could you please test it out on the react app and let me know your results?
Thank you! Joyce
Hi PikaJoyce,
Thanks so much for your kindness. I appreciate all those time you spent helping me find the issue in my code. I have spent a decent amount of time going over my codes and the documentation you provided. Here is my understanding:
const disconnect = () => newRoom.disconnect()
newRoom.once('disconnected', () => {
setTimeout(() => setRoom(null))
window.removeEventListener('beforeunload', disconnect)
isMobile && window.removeEventListener('pagehide', disconnect)
})
window.twilioRoom = newRoom
window.addEventListener('beforeunload', disconnect)
isMobile && window.addEventListener('pagehide', disconnect)
This part of the code is not an issue. It means when the beforeunload
event is fired for the window, we disconnect the room. I think this is used to disconnect the room if the user closes the webpage. Afterwards, if the room has been disconnected, we will remove our cached room state and remove the window event listener. All these make sense and the problem still persists after I remove this block of code.
I am able to reproduce the issue in your react app.
I have forked it here. Please see the README.md
for more details.
I have made a screencast and here is a download link
Please feel free to reach me with any questions.
Sincerely, Jerry Shan
Hi @nuynait,
Thanks for the update and for trying it out! I'll begin some investigations today and update you when I get to it!
Best, Joyce
Hey @nuynait,
Thank you for your patience! So I got to try it out. I have so far been able to test two scenarios.
I believe that this is a known issue after consulting with the team about this. Here's a little bit of insight as to why this happens. If we look at this diagram we can see that Twilio does not have a hand in the media exchange in P2P rooms. So in cases like this, if a participant loses network and reconnection is never established within 30 seconds, both participants lose connection to the room as they're both thrown into a reconnecting state since we do not know which of the two participants have network issues.
The workaround for this would be for the person who loses network (and is unable to reconnect) to actually leave the room before the reconnection timer runs out. This should allow for the other participant that does not have network issues to stay in the room.
As this is a known issue, I've filed an internal ticket to track this issue (VIDEO-9283)
I will be keeping this issue open and update this thread as they come.
Thank you again for your patience and thorough explanations!
Best, Joyce
Hi @PikaJoyce,
Is there any news about this issue? I still experience the same problem. You mentioned this workaround:
The workaround for this would be for the person who loses network (and is unable to reconnect) to actually leave the room before the reconnection timer runs out. This should allow for the other participant that does not have network issues to stay in the room.
How could I achieve this? As I understand if such participant loses internet connection he can't really tell that he needs to disconnect form the room. Maybe it can be handled on the backend? Perhaps there is some Video REST API route that can be used to disconnect specific participant?
Hi @artemSQS,
Thank you for the question. Currently there hasn't been any movement as fixing this issue will require an entire overhaul to our current product to solve this.
My suggestion to work around this is you can listen in on the reconnecting
room event and disconnect that participant as soon as the attempt to reconnect occurs.
Best, Joyce
This only happens under room type
peer-to-peer
it works all right on room typegroup
.Reproduce
Steps to reproduce the issue:
Expected behavior:
Only person B lost the connection. The room state for person A should not be affected and remain connected.
Actual behavior:
The room state for person A changed to reconnecting for a while then eventually drop to disconnected.
Code
Code for room creation and access:
We create the room in nodeJS server and join the room in front-end React using the token provided from the server.
In nodeJS server, we created the room using:
Here is our connect function in the front-end React:
Logs
Here is the log for person A that should not change the room state when person B gets disconnected.
Short version:
More detailed:
One more thing
One thing that I want to point out is that it only be able to reproduce on our deployed server.
To reproduce this issue on localhost, I will have to do exactly the following:
In that case, I can reproduce that and both A and B will
reconnecting
and eventually change todisconnected
.Note that if I:
In this case, disconnecting any network (COM-A or COM-B or COM-C) will not cause any unexpected behavior. Everything is as expected.
reconnecting
and thendisconnected
.reconnecting
and thendisconnected
.Footer
Software versions: