Problems connecting IP camera

Greetings.

Environment Info:
Server Ubuntu Ubuntu 18.04.4 LTS
Server language Node.js
Client language Javascript
OpenVidu version : 2.22.0

I am trying to add support for IP cameras that server provides to individual classrooms (sessions)
i followed tutorial IP cameras - OpenVidu Docs and server code look like this:

// mine object where i keep info about individual classrooms
// classroom.session is openvidu session object created by function OV.createSession(properties)
var classroom = SESSIONS["6270d936fd31f16e6e51e0a1"]


var connectionProperties = {
	type: "IPCAM",
	rtspUri: "rtsp://147.251.36.114:7777/live1.sdp",
	adaptativeBitrate: true,
	onlyPlayWithSubscribers: false,
	networkCache: 1000
};

classroom.session.createConnection(connectionProperties).then(async c => {
	console.log("IP camera created")
		
	// fetch data after 5 sec about connections
	async function f(){
		await classroom.session.fetch()
		console.log(classroom.session.connections)
	}
	const myTimeout = setTimeout(f, 5000);
		
		
}).catch(error => {console.log("IP camera Error 1");console.log(error)});

when i execute this code i end up with this object in mine console

Connection {
	publishers: [],
	subscribers: [],
	connectionId: 'con_GOM6HauHBR',
	status: 'pending',
	createdAt: 1663587115979,
	activeAt: null,
	location: null,
	platform: null,
	clientData: null,
	token: 'wss://polygraf.app:4443?sessionId=ses_VdtYGZKNRU&token=tok_WsM0H0mdLHaLXvyR',
	connectionProperties: {
		type: 'WEBRTC',
		data: undefined,
		record: true,
		role: 'PUBLISHER',
		kurentoOptions: null,
		rtspUri: null,
		adaptativeBitrate: null,
		onlyPlayWithSubscribers: null,
		networkCache: null
	},
	role: 'PUBLISHER',
	serverData: undefined
}

But nothing has started. (even if i waited longer) Publisher was never added to this connection and for some reason in connectionProperties there is type set to be WEBRTC not IPCAM how it should be.

I did not found any errors either in console or in OpenVidu log. In OpenVidu i did not found any information about connection with id con_GOM6HauHBR.

Currently i am not sure where i can find out where was a problem. If error is that he could not get to that ip camera (tested form server he could reach it) or if there are any problems like i should in some configurations allow IP cameras

I would appreciate any help or hint where i can find out what went wrong.

If the type property of the Connection object is “WEBRTC”, then it won’t work with an IP camera. So the problem must be somewhere in the creation of the Connection. Something is not working properly, and OpenVidu is simply creating your Connection with the default values, ignoring your ConnectionProperties.
What happens if you consult the Connection object directly using the REST API? I mean, for example navigating directly to https://YOUR_OPENVIDU_IP/openvidu/api/sessions in your browser. That will send a GET to retrieve the list of active Sessions, including its Connections. Does that also return the Connection with a WEBRTC type?

Hello, thanks for reply.
In /openvidu/api/sessions there is no info about that connection for IP camera, there is only connection from my browser (using it to setup classroom and check if client get any info about IP camera, which he doesn’t )
{

 "numberOfElements":1,
 "content":[
  1. {
     "id":"ses_CvZ32YKuYR",
     "object":"session",
     "sessionId":"ses_CvZ32YKuYR",
     "createdAt":1663656099842,
     "recording":false,
     "mediaMode":"ROUTED",
     "recordingMode":"MANUAL",
     "defaultRecordingProperties":{
       "name":"",
       "hasAudio":true,
       "hasVideo":true,
       "outputMode":"COMPOSED",
       "recordingLayout":"BEST_FIT",
       "resolution":"1280x720",
       "frameRate":25,
       "shmSize":536870912},
     "customSessionId":"",
     "forcedVideoCodec":"MEDIA_SERVER_PREFERRED",
     "forcedVideoCodecResolved":"VP8",
     "allowTranscoding":false,
     "connections":{
       "numberOfElements":1,
       "content":[
        1. {
           "id":"con_Jgb8kuEIda",
           "object":"connection",
           "status":"active",
           "connectionId":"con_Jgb8kuEIda",
           "sessionId":"ses_CvZ32YKuYR",
           "createdAt":1663656101897,
           "activeAt":1663656102055,
           "location":"unknown",
           "ip":"[CENSORED]",
           "platform":"Chrome 105.0.0.0 on Windows 10 64-bit",
           "token":"wss://polygraf.app:4443?sessionId=ses_CvZ32YKuYR&token=tok_K6JPphBDmsryeX3e",
           "type":"WEBRTC",
           "record":true,
           "role":"PUBLISHER",
           "kurentoOptions":null,
           "customIceServers":{},
           "rtspUri":null,
           "adaptativeBitrate":null,
           "onlyPlayWithSubscribers":null,
           "networkCache":null,
           "serverData":"",
           "clientData":"{"clientData":"asdawadsad","clientRole":"student","author":"UID_152","ID":"UID_152"}",
           "publishers":[
            1. {
               "createdAt":1663656102489,
               "streamId":"str_CAM_QzNT_con_Jgb8kuEIda",
               "mediaOptions":{
                 "hasAudio":true,
                 "audioActive":true,
                 "hasVideo":true,
                 "videoActive":true,
                 "typeOfVideo":"CAMERA",
                 "frameRate":25,
                 "videoDimensions":"{"width":480,"height":320}",
                 "filter":{}}}],
           "subscribers":{}}]}}]

}

so what that could mean ? becouse

      classroom.session.fetch()
      console.log(classroom.session.connections)

at least give me that connection was created

Any idea?

Ok, i solved it. Somehow i failed to correctly update Node-openvidu-client on my server so there wasn’t code that handle ip cameras so that is why he ignored that.
Thanks for your time.
Michal Klíma

I mean, in order to retrieve the information, the GET to /openvidu/api/sessions should be done after you have called the method to create the IPCAM connection.
You have your Session created, you create your Connection of type IPCAM, and then if you perform the GET to list your sessions, the retrieved Sessions must have the IPCAM Connection.

I am not familiar with the custom logic of your app, but the steps you must do to publish an IP camera are the following:

  1. Create a Session
  2. Create a Connection of type IPCAM. This will automatically publish the IP camera stream to the Session.
  3. Create any other Connection of type WEBRTC and connect to the Session regular users in order to subscribe to the IP camera stream (or any other stream published to the Session).

Steps 2 and 3 are actually interchangeable. The thing is: I believe that step 2 is not being properly done in your application, whatever the reason might be. For some reason your ConnectionProperties are not reaching OpenVidu and it is using the default properties (which is type WEBRTC). That’s why I was asking to see the result of a GET to /openvidu/api/sessions after your steps 1, 2 and 3.