Configuration for Recording in Rest API

**Where should i set true to recording property . I created session api as like below. but recording value will always returning false.
Dont know where to configure for enabling recording as true in REST API.

Kindly help to resolve this issue.**

    createSession(sessionId) {
        return new Promise((resolve, reject) => {
            var data = JSON.stringify({ customSessionId: sessionId,
                "recording": true,
                "mediaMode": "ROUTED",
                "recordingMode": "ALWAYS",
                "defaultOutputMode": "COMPOSED",
                "defaultRecordingLayout": "BEST_FIT"});
            axios
                .post(OPENVIDU_SERVER_URL + '/api/sessions', data, {
                    headers: {
                        Authorization: 'Basic ' + btoa('OPENVIDUAPP:' + OPENVIDU_SERVER_SECRET),
                        'Content-Type': 'application/json',
                    },
                })
                .then((response) => {
                    console.log('CREATE SESION', response);
                    //alert(response.OPENVIDU_STREAMS_VIDEO_MAX_RECV_BANDWIDTH);
                    fetch(OPENVIDU_SERVER_URL + '/api/sessions/'+sessionId , {
                        method: 'GET',
                        headers: {
                            Authorization: 'Basic ' + btoa('OPENVIDUAPP:' + OPENVIDU_SERVER_SECRET),
                            'Content-Type': 'application/json',
                        }
                    })
                        .then(res => res.json())
                        .then(
                            (result) => {
                                console.log("GETSESS"+result.recording);//Always returning false
    
                            },
                            (error) => {
                                alert(error);
                                console.log(error);
                            }
                        );
                    resolve(response.data.id);
                })
                .catch((response) => {
                    var error = Object.assign({}, response);
                    if (error.response.status === 409) {
                        resolve(sessionId);
                    } else {
                        console.log(error);
                        console.warn(
                            'No connection to OpenVidu Server. This may be a certificate error at ' +
                            OPENVIDU_SERVER_URL,
                        );
                        if (
                            window.confirm(
                                'No connection to OpenVidu Server. This may be a certificate error at "' +
                                OPENVIDU_SERVER_URL +
                                '"\n\nClick OK to navigate and accept it. ' +
                                'If no certificate warning is shown, then check that your OpenVidu Server is up and running at "' +
                                OPENVIDU_SERVER_URL +
                                '"',
                            )
                        ) {
                            window.location.assign(OPENVIDU_SERVER_URL + '/accept-certificate');
                        }
                    }
                });
        });
    }

@hemalatha, no need to pass “recording”:true while creating Session. You need to enable the Recording from the config file.

  • Go to openVidu installation folder, in most cases it would be “/opt/openvidu”.
  • Edit the ".env" file e.g sudo nano .env
  • Search for the “OPENVIDU_RECORDING” and change the value from false to true.
    OPENVIDU_RECORDING=true
  • Restart the openvidu services
    and then try the Rest API to check the same.

@rohit.roy… Thanks for reply but I am usin Reacjjs, in node_modules there is no .env file. i checked and i didnt find /opt/openvidu

@hemalatha, .env file is the part of Openvidu installation. Where have you installed Openvidu and how you start the Openvidu services.

@rohit.roy… deployed openvidu in aws by using cloud formation as like in aws deployment in docs of openvidu website. and in reactjs components, openvidu-browser installed by command : npm install openvidu-browser…attached image for reference

You need to enable recording on openvidu server. Login to your EC2 instance and change in .env file over there.

@rohit.roy… Thank u … i do and let u know

okay, also i see the create token, session connect and Publish session is missing in your code. To record the session properly, stream should be published. So the sequence should be like this to record the session properly.

  • Initialise session object (using method initSession())
  • Create session
  • Create token with PUBLISHER role
  • Connect session with the token received (using method session.connect() )
  • Initiate Publisher ( using method initPublihser() )
  • Publish session ( using session.publish() )

@rohit.roy. i used these points in joinsession function. In AWS, in EC2 , i just mapped created ip in ec2 to site like https://xxxx.co.in with letsEncrypt. can u help to find where .env file located?

Default installation path /opt/openvidu as root user ( $ sudo su ).
SSH the AWS server and go to this directory to edit the .env file.

Or you can try searching it from Console like this
locate .env

@rohit.roy … Thank u… Successfully configured.