Cannot Subscribe to 2+ Different Sessions on Same Webpage

Hello. We are building an app (OV CE 2.20.0 for now) in which a user will need to subscribe to more than one session on the same webpage (its for remote test proctoring). We do not publish from this app, we only subscribe.

In my webpage, when subscribing to the first session, everything works fine.

However, when subscribing to additional sessions, the streamPlaying event does not fire. All goes well to that point. I’m pretty sure I do everything correctly. I call OpenVidu.initSession separately, with the correct tokens. videoElementCreated events are fired as expected for all subscribers. streamPlaying fires for the first subsciber only.

I noticed in the OpenVidu server logs these lines which seem to indicate what is happening:

openvidu-server_1 | [INFO] 2022-01-17 21:57:07,974 [AbstractJsonRpcClientWebSocket-reqResEventExec-e2-t744] io.openvidu.server.kurento.core.KurentoParticipantEndpointConfig - KMS event [IceComponentStateChange]: → endpoint: con_KnPs8bLKeZ_str_CAM_Prj2_con_XcDYRIxTIv (subscriber) | state: CONNECTING | componentId: 2 | streamId: 1 | timestamp: 1642456627973
openvidu-server_1 | [INFO] 2022-01-17 21:57:08,082 [AbstractJsonRpcClientWebSocket-reqResEventExec-e2-t744] io.openvidu.server.kurento.core.KurentoParticipantEndpointConfig - KMS event [IceComponentStateChange]: → endpoint: con_KnPs8bLKeZ_str_CAM_Prj2_con_XcDYRIxTIv (subscriber) | state: READY | componentId: 1 | streamId: 1 | timestamp: 1642456628081
openvidu-server_1 | [INFO] 2022-01-17 21:57:08,082 [AbstractJsonRpcClientWebSocket-reqResEventExec-e2-t741] io.openvidu.server.kurento.core.KurentoParticipantEndpointConfig - KMS event [IceComponentStateChange]: → endpoint: con_KnPs8bLKeZ_str_CAM_Prj2_con_XcDYRIxTIv (subscriber) | state: CONNECTED | componentId: 1 | streamId: 1 | timestamp: 1642456628081
openvidu-server_1 | [INFO] 2022-01-17 21:57:08,082 [AbstractJsonRpcClientWebSocket-reqResEventExec-e2-t740] io.openvidu.server.kurento.core.KurentoParticipantEndpointConfig - KMS event [NewCandidatePairSelected]: → endpoint: con_KnPs8bLKeZ_str_CAM_Prj2_con_XcDYRIxTIv (subscriber) | local: candidate:7 1 UDP 1679819007 34.234.9.225 54561 typ srflx raddr 172.31.84.152 rport 54561 | remote: candidate:1 1 UDP 1686052863 96.241.108.213 54891 typ srflx | timestamp: 1642456628081
openvidu-server_1 | [INFO] 2022-01-17 21:57:09,973 [AbstractJsonRpcClientWebSocket-reqResEventExec-e2-t740] io.openvidu.server.kurento.core.KurentoParticipantEndpointConfig - KMS event [IceGatheringDone] → endpoint: con_KnPs8bLKeZ_str_CAM_Prj2_con_XcDYRIxTIv (subscriber) | timestamp: 1642456629972
openvidu-server_1 | [INFO] 2022-01-17 21:57:15,060 [AbstractJsonRpcClientWebSocket-reqResEventExec-e2-t740] io.openvidu.server.kurento.core.KurentoParticipantEndpointConfig - KMS event [IceComponentStateChange]: → endpoint: con_KnPs8bLKeZ_str_CAM_Prj2_con_XcDYRIxTIv (subscriber) | state: FAILED | componentId: 2 | streamId: 1 | timestamp: 1642456635059

So, my question is, is this possible? If so, do you have any idea what I may be doing wrong?

Thank you for your help as always.

Hi @mrussiello , I’m pretty sure this is possible because we’ve done it on occasion for testing proposes.

I’ll bet you’re doing something wrong in the client side using openvidu-browser library. Take account that you’ll need initialize two OpenVidu object in your webapp for subscribing to two different sessions. A quick sample will be:

// Initialize OpenVidu objects
var OV1 = new OpenVidu();
var OV2 = new OpenVidu();

// Initialize sessions
vat firstSession = OV.initSession();
vat secondSession = OV.initSession();

// Connect sessions
firstSession.connect(token);
secondSession.connect(token); // --> here the token must be created using the another session ID

// Listen fot streamCreated Events
firstSession.on('streamCreated', (event) => {

});

secondSession.on('streamCreated', (event) => {

});

What kind of client technology are you using? Are you using regular browsers on the client side?

Thank you Pablo and Carlos. Yes, just using up-to-date Firefox and Chrome on Win10. As you suggested, I was creating a separate OpenVidu object for each sessionId and a separate session from each OV object and a different token for each sessionId. Everything looked great until the streamPlaying event did not fire for the second session.

The only other different thing is that each session pointed to a different instance of OpenVidu CE (two different AWS instances). The urls were correct and I can see the OV and Kurento logs on each instance. The only unusual thing was the log entry on the second server (used for the second session) I included in my email:

openvidu-server_1 | [INFO] 2022-01-17 21:57:15,060 [AbstractJsonRpcClientWebSocket-reqResEventExec-e2-t740] io.openvidu.server.kurento.core.KurentoParticipantEndpointConfig - KMS event [IceComponentStateChange]: → endpoint: con_KnPs8bLKeZ_str_CAM_Prj2_con_XcDYRIxTIv (subscriber) | state: FAILED | componentId: 2 | streamId: 1 | timestamp: 1642456635059

Should it make a different if the multiple sessions are on different servers?

Some browsers have issues if you try to connect to two different media servers from the same web page.

To avoid any issue, you should configure the same PEM certificate in both media servers.

To do it in OpenVidu, you should generate a new Kurento docker image with the same PEM certificate configured in /etc/kurento/modules/kurento/WebRtcEndpoint.conf.ini file.

More information here:
https://doc-kurento.readthedocs.io/en/latest/features/security.html#media-plane-security-dtls

Regards

Thank you so much for this advice Micael. I think this may be my problem.

I’m new to docker and spending some time learning. But I cannot figure out how to edit the /etc/kurento/modules/kurento/WebRtcEndpoint.conf.ini file, since I cannot find it on my CE instance or elsewhere. I understand how to use docker-compose but I really need a hint as to how to edit the file and create a new image. Can you please point me in the right direction?

Nevermind on help. I found what I needed at Frequently Asked Questions — Kurento 6.16.0 documentation

Thanks again. I’ve been able to verify that this issue only exists for Firefox. It works fine in Chrome, Edge, and Safari.

Cheers!

I’m glad to see you finally solve your issue.

请问您是怎么解决的呢,能否告知我正确的方式