muaz-khan / RTCMultiConnection-Server

RTCMultiConnection socket.io server (npm install rtcmulticonnection-server)
https://muazkhan.com:9001/
MIT License
274 stars 146 forks source link

Is this a bug? Sometimes an initiator with connection.userid = roomid gets a new UserID when opening a room #5

Open ghost opened 5 years ago

ghost commented 5 years ago

There are strange moments in the work of the code. In my case, the initiator has the parameters:

connection.autoCloseEntireSession = true
connection.userid = roomid

The script is very simple. Initiator refreshes the page. The server closes the room. The admin panel shows that the room is missing.

BUT! If the initiator tries to return and reopen the room, then RTCMultiConnection reports to the console that a user with that name already exists and gives him a new UserID. At the same time, the admin panel shows that there are no rooms at all.

In my case, only restarting the server node server.js or changing the name of the room helps.

What could it be? Is this a bug or incorrect server installation?

muaz-khan commented 5 years ago

Seems like a bug. However I need to test and reproduce it. Hopefully next updates will fix it. Regards

ghost commented 5 years ago

I get a bug in the following way:

  1. Turn on the server
  2. Log in to the admin panel
  3. Initiator creates a room
  4. Broadcaster connects
  5. The admin panel shows that there are two users and one room.
  6. Turn off the server. Turn on the server.
  7. Admin panel reports Signaling-Server (users: 2, rooms: 0)
  8. After Disconnect Initiator triggers startCheckingForOwnerOpenRoom ()
function startCheckingForOwnerOpenRoom() {
    connection.checkPresence(roomid, function(isOwnerOnline) {
        if (isOwnerOnline === false) {
            connection.close();
            connection.closeSocket();
            connection.userid = roomid;

            connection.open(roomid, function(isRoomOpen, error) {   
                if (isRoomOpen === false) {
                    console.log('connection.open: isRoomOpen false');
                    connection.close();
                    connection.closeSocket();
                    setTimeout(function() {
                        startCheckingForOwnerOpenRoom();
                    }, 1000);
                } else {
                    console.log('connection.open: isRoomOpen true');
                }
            });

            afterConnectingSocket();
            //return;
        }
        setTimeout(startCheckingForOwnerOpenRoom, 2000);
    });
}
  1. In the browser console at the Initiator, the RTCMultiConnection reports that a user with the same name exists and a new UserID is assigned to the Initiator.

As a result, connection.userid != roomid and the Initiator cannot open the room.