New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initiator can't rejoin a room after leaving connection #428

Open
suziesirena opened this Issue Jul 6, 2017 · 22 comments

Comments

Projects
None yet
@suziesirena

suziesirena commented Jul 6, 2017

Hi,

My problem is :

If a participant leaves the connection (by refreshing the page for example), he can reconnect to the same connection.

But if the initiator leaves the connection (by refreshing the page for example), the messages are not sent to the participants until they reconnect themselves (participants array is empty).

Her is the code:

// Initialization
   connection = new RTCMultiConnection(channel_ID)
   connection.socketURL = '/'
   connection.autoCloseEntireSession = false
   connection.onmessage = onmessage
   connection.sessionid = channel_ID
   connection.socketCustomEvent = 'custom-message'
// Connection
   connection.openOrJoin(channel_ID, function() {
    })

Did I missed something?

@jamesthoughton

This comment has been minimized.

Show comment
Hide comment
@jamesthoughton

jamesthoughton Jul 7, 2017

I get this issue as well... been scratching my head for a while

jamesthoughton commented Jul 7, 2017

I get this issue as well... been scratching my head for a while

@rayj00

This comment has been minimized.

Show comment
Hide comment
@rayj00

rayj00 Jul 13, 2017

I'm still scratching my head trying to figure out what Muaz's goal is in all of this?
Granted, I admire his ambition and him providing all of the neat code, but since there are no comments
in the code, and I consider myself very green with WebRTC, I am struggling to get anything to work correctly. Right now I am playing with Multiple-Broadcasters-Many Viewers. Very complex code. It does not work as I might expect and there are major issues. As Muaz rarely answers questions, is it entirely up to us to find and fix bugs? If that's the case, I guess I'm screwed as it will take me quite a long time to figure out the code. Reporting the issues are not getting anywhere. Aren't demos supposed to work by default?

rayj00 commented Jul 13, 2017

I'm still scratching my head trying to figure out what Muaz's goal is in all of this?
Granted, I admire his ambition and him providing all of the neat code, but since there are no comments
in the code, and I consider myself very green with WebRTC, I am struggling to get anything to work correctly. Right now I am playing with Multiple-Broadcasters-Many Viewers. Very complex code. It does not work as I might expect and there are major issues. As Muaz rarely answers questions, is it entirely up to us to find and fix bugs? If that's the case, I guess I'm screwed as it will take me quite a long time to figure out the code. Reporting the issues are not getting anywhere. Aren't demos supposed to work by default?

@qedawkins

This comment has been minimized.

Show comment
Hide comment
@qedawkins

qedawkins Jul 13, 2017

I was able to fix this issue for me by changing a line in the Signaling-Server.js file.

if (autoCloseEntireSession == 'false' && sessionid == socket.userid) { socket.shiftModerationControlBeforeLeaving = true; }

Line 97

to

if (autoCloseEntireSession == 'false' && Object.keys(listOfUsers).length == 1) { socket.shiftModerationControlBeforeLeaving = true; }

There is probably a better way to do this but the issue was in essence that the userid recieved from socket.handshake.query wasn't equal to the sessionid for the first user to join at this point in the code (but it does get set to the sessionid later from what I can tell) and instead was a randomly generated userid like everyone who joined afterwards. This will make is so when the initiator leaves, the next user in listOfUsers will inherit the initiator status and when the original initiator joins back it will be like they are joining as a normal user.

This feels like a bit of a hacky solution, and considering that it works properly in the web demos, I'm fairly certain there's a better fix, but this worked for me.

qedawkins commented Jul 13, 2017

I was able to fix this issue for me by changing a line in the Signaling-Server.js file.

if (autoCloseEntireSession == 'false' && sessionid == socket.userid) { socket.shiftModerationControlBeforeLeaving = true; }

Line 97

to

if (autoCloseEntireSession == 'false' && Object.keys(listOfUsers).length == 1) { socket.shiftModerationControlBeforeLeaving = true; }

There is probably a better way to do this but the issue was in essence that the userid recieved from socket.handshake.query wasn't equal to the sessionid for the first user to join at this point in the code (but it does get set to the sessionid later from what I can tell) and instead was a randomly generated userid like everyone who joined afterwards. This will make is so when the initiator leaves, the next user in listOfUsers will inherit the initiator status and when the original initiator joins back it will be like they are joining as a normal user.

This feels like a bit of a hacky solution, and considering that it works properly in the web demos, I'm fairly certain there's a better fix, but this worked for me.

@suziesirena

This comment has been minimized.

Show comment
Hide comment
@suziesirena

suziesirena Jul 15, 2017

thanks @qedawkins,

it works for me.

suziesirena commented Jul 15, 2017

thanks @qedawkins,

it works for me.

@bhaumikpandhi

This comment has been minimized.

Show comment
Hide comment
@bhaumikpandhi

bhaumikpandhi Aug 3, 2017

I'm facing the same problem, joining room is not working.

The program goes infinite giving error "Session-Descriptions not found. Rechecking.."

bhaumikpandhi commented Aug 3, 2017

I'm facing the same problem, joining room is not working.

The program goes infinite giving error "Session-Descriptions not found. Rechecking.."

@ajingopi

This comment has been minimized.

Show comment
Hide comment
@ajingopi

ajingopi Aug 18, 2017

connection.onUserStatusChanged = function(event) {
    if (sessionDetails.userType == "participant" && event.status === 'offline') { //manually set by me for all participants using a cookie
        reCheckRoomPresence(); //window.location.reload(false); this works on chrome/firefox
    }
};

function reCheckRoomPresence(){
    var findWhenCustomerReconnectsToTheRoom = setInterval(function(){
        connection.checkPresence(sessionDetails.token, function(isRoomExists) {
            if(isRoomExists) {
                connection.join(sessionDetails.token); //sessionDetails.token is room-id
                clearInterval(findWhenCustomerReconnectsToTheRoom);
                return;
            }
        });
    }, 1);
}

ajingopi commented Aug 18, 2017

connection.onUserStatusChanged = function(event) {
    if (sessionDetails.userType == "participant" && event.status === 'offline') { //manually set by me for all participants using a cookie
        reCheckRoomPresence(); //window.location.reload(false); this works on chrome/firefox
    }
};

function reCheckRoomPresence(){
    var findWhenCustomerReconnectsToTheRoom = setInterval(function(){
        connection.checkPresence(sessionDetails.token, function(isRoomExists) {
            if(isRoomExists) {
                connection.join(sessionDetails.token); //sessionDetails.token is room-id
                clearInterval(findWhenCustomerReconnectsToTheRoom);
                return;
            }
        });
    }, 1);
}

Repository owner deleted a comment from rayj00 Aug 18, 2017

@imail2pankaj

This comment has been minimized.

Show comment
Hide comment
@imail2pankaj

imail2pankaj May 8, 2018

@muaz-khan I have also same issue, but here what I want to do is if initiator leaves then another user should become the initiator, if another user leaves the room so on...

How can I achieve this?

imail2pankaj commented May 8, 2018

@muaz-khan I have also same issue, but here what I want to do is if initiator leaves then another user should become the initiator, if another user leaves the room so on...

How can I achieve this?

@muaz-khan

This comment has been minimized.

Show comment
Hide comment
@muaz-khan

muaz-khan May 8, 2018

Owner

This issue will be fixed soon. Just working on that now.

Owner

muaz-khan commented May 8, 2018

This issue will be fixed soon. Just working on that now.

@rayj00

This comment has been minimized.

Show comment
Hide comment
@rayj00

rayj00 May 8, 2018

I do not believe another should become initiator. That defeats the purpose of being the initiator!
However, the original initiator should be able to rejoin the conference for sure.
That said, after the conference is started, what does the initiator have to do anyway?

rayj00 commented May 8, 2018

I do not believe another should become initiator. That defeats the purpose of being the initiator!
However, the original initiator should be able to rejoin the conference for sure.
That said, after the conference is started, what does the initiator have to do anyway?

@muaz-khan

This comment has been minimized.

Show comment
Hide comment
@muaz-khan

muaz-khan May 8, 2018

Owner

I'm working on storing room-ids on the nodejs as well. So one will join a room based on room-id; not based on initiator's user-id. checkPresence method will also check for room-id instead of initiator's id. So initiator or any person can leave or rejoin without affecting the room on nodejs.

Owner

muaz-khan commented May 8, 2018

I'm working on storing room-ids on the nodejs as well. So one will join a room based on room-id; not based on initiator's user-id. checkPresence method will also check for room-id instead of initiator's id. So initiator or any person can leave or rejoin without affecting the room on nodejs.

@imail2pankaj

This comment has been minimized.

Show comment
Hide comment
@imail2pankaj

imail2pankaj May 9, 2018

@rayj00 Thanks for your reply.

Actually I am working on a group chat where number of people can join the room. When room initiator leaves the room the no one is able to join the room as well as initiator.

My only concern is after initiator leaving the room any user can join that room as well as initiator.

imail2pankaj commented May 9, 2018

@rayj00 Thanks for your reply.

Actually I am working on a group chat where number of people can join the room. When room initiator leaves the room the no one is able to join the room as well as initiator.

My only concern is after initiator leaving the room any user can join that room as well as initiator.

@VShtaba

This comment has been minimized.

Show comment
Hide comment
@VShtaba

VShtaba May 12, 2018

@muaz-khan the changes room-id instead of user-id will improve the stability of Multiple Broadcasters for a lot of Viewers?

VShtaba commented May 12, 2018

@muaz-khan the changes room-id instead of user-id will improve the stability of Multiple Broadcasters for a lot of Viewers?

@imail2pankaj

This comment has been minimized.

Show comment
Hide comment
@imail2pankaj

imail2pankaj May 21, 2018

Hello @muaz-khan, have you solved the issue of initiator?

imail2pankaj commented May 21, 2018

Hello @muaz-khan, have you solved the issue of initiator?

@VShtaba

This comment has been minimized.

Show comment
Hide comment
@VShtaba

VShtaba May 28, 2018

@muaz-khan you have a very interesting mechanism for reducing broadkaster load. This allows to connect to the conference a lot of interesting people with weak technical capabilities.
Unfortunately, without the automatic connection of the initiator to the chat room I can not yet use RTCMultiConnection in a live conference. Our nongovernmental organization works in a zone with a very unstable internet connection. I look forward to resolving this problem.

VShtaba commented May 28, 2018

@muaz-khan you have a very interesting mechanism for reducing broadkaster load. This allows to connect to the conference a lot of interesting people with weak technical capabilities.
Unfortunately, without the automatic connection of the initiator to the chat room I can not yet use RTCMultiConnection in a live conference. Our nongovernmental organization works in a zone with a very unstable internet connection. I look forward to resolving this problem.

@rodrigodocarmo1

This comment has been minimized.

Show comment
Hide comment
@rodrigodocarmo1

rodrigodocarmo1 Jun 7, 2018

I'm still with the same issue

rodrigodocarmo1 commented Jun 7, 2018

I'm still with the same issue

@viro24

This comment has been minimized.

Show comment
Hide comment
@viro24

viro24 Jun 8, 2018

Hi there,
you can work around this behavior:

  • set autoclosesession to false
  • pass another URL param like "key=x"
  • when opening and joining a room check for existance of key
  • after Initiator disconnects/reloads page:
  • set userid of Initiator to roomid
  • open room
  • send custom message to all participants "initiatorReconnected"
  • oncustomMessage is used to rejoin the room
  • renegotiate on Initiator side

hope this helps :]

viro24 commented Jun 8, 2018

Hi there,
you can work around this behavior:

  • set autoclosesession to false
  • pass another URL param like "key=x"
  • when opening and joining a room check for existance of key
  • after Initiator disconnects/reloads page:
  • set userid of Initiator to roomid
  • open room
  • send custom message to all participants "initiatorReconnected"
  • oncustomMessage is used to rejoin the room
  • renegotiate on Initiator side

hope this helps :]

muaz-khan added a commit that referenced this issue Jun 9, 2018

#428 also added support for MSEdge-Screen-Capturing
Now you can set passwords using "connection.password".

Now if initiator leaves, he can rejoin same room.
@muaz-khan

This comment has been minimized.

Show comment
Hide comment
@muaz-khan

muaz-khan Jun 9, 2018

Owner

Please clone RTCMultiConnection and try again. Relevant commit: 157c9e5

Owner

muaz-khan commented Jun 9, 2018

Please clone RTCMultiConnection and try again. Relevant commit: 157c9e5

@rodrigodocarmo1

This comment has been minimized.

Show comment
Hide comment
@rodrigodocarmo1

rodrigodocarmo1 Jun 10, 2018

I tried the new version but didn't worked yet :(. When I refresh the initiator's window no one can connect.

rodrigodocarmo1 commented Jun 10, 2018

I tried the new version but didn't worked yet :(. When I refresh the initiator's window no one can connect.

@agam16

This comment has been minimized.

Show comment
Hide comment
@agam16

agam16 Jul 16, 2018

Hi @muaz-khan , i am also facing the same issue. If a user creates a room & then he leaves, he is not able to connect. I am scratching my head to get a workaround, Please suggest.

Thanks

agam16 commented Jul 16, 2018

Hi @muaz-khan , i am also facing the same issue. If a user creates a room & then he leaves, he is not able to connect. I am scratching my head to get a workaround, Please suggest.

Thanks

@duahimanshu100

This comment has been minimized.

Show comment
Hide comment
@duahimanshu100

duahimanshu100 Jul 26, 2018

Any solutions to this yet? Its not working. Moderator can't join the room again. Instead it creates the room again with same name.

duahimanshu100 commented Jul 26, 2018

Any solutions to this yet? Its not working. Moderator can't join the room again. Instead it creates the room again with same name.

@jamesthoughton

This comment has been minimized.

Show comment
Hide comment
@jamesthoughton

jamesthoughton Jul 26, 2018

The solution is to stop using this library and use WebRTC by itself.

jamesthoughton commented Jul 26, 2018

The solution is to stop using this library and use WebRTC by itself.

muaz-khan added a commit that referenced this issue Oct 2, 2018

New Release: RTCMultiConnection 3.4.7
Closed #639, Fixed ##428, Fixed ##638

For more info, please check: #639
@VShtaba

This comment has been minimized.

Show comment
Hide comment
@VShtaba

VShtaba Oct 15, 2018

Thanks for fixing the library for automatically join rejoin rooms. It's great! Please tell me how to do automatically rejoin rooms in case of oneway session?

Scenario: Broadcaster communicate with each other in the room. Viewers are connected to this room using an oneway session. Viewers users hear and see everything that happens in the room. What needs to be done so that after Internet disconnection Viewers can automatically join to the room?

VShtaba commented Oct 15, 2018

Thanks for fixing the library for automatically join rejoin rooms. It's great! Please tell me how to do automatically rejoin rooms in case of oneway session?

Scenario: Broadcaster communicate with each other in the room. Viewers are connected to this room using an oneway session. Viewers users hear and see everything that happens in the room. What needs to be done so that after Internet disconnection Viewers can automatically join to the room?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment