Video Call functionality not working

Hello

After Call accepted successfully it throws an error.

code: “ERR_CALL_ONGOING_TO_INVALID”
message: “The call status cannot be updated from ongoing to unanswered.”

Hello @rutul ,

Can you please provide more details like the SDK version you are using, a small code snippet & steps to reproduce the issue?

Warm Regards,

CometChat Pro
Mayur Bhandari

I am using Javascript SDK 2.3.0 .
https://unpkg.com/@cometchat-pro/chat@2.3.0/CometChat.js

Here is my initiate call code.

`var receiverID = guid;
            var callType = CometChat.CALL_TYPE.VIDEO;
            var receiverType = CometChat.RECEIVER_TYPE.GROUP;

            var call = new CometChat.Call(receiverID, callType, receiverType);

            CometChat.initiateCall(call).then(
              outGoingCall => {
                 alert('call initiated');
                 console.log("Call initiated successfully:", outGoingCall);
                 localStorage.setItem('sessionId',outGoingCall.sessionId);
                // perform action on success. Like show your calling screen.
            },
            error => {
                console.log("Call initialization failed with exception:", error);
            }
            );

`

Hello @rutul,

Since the issue occurs when you accept a call. Can you please share the relevant code snippet as well?

Warm Regards,

CometChat Pro
Mayur Bhandari

One User Accepts the call for that it shows a calling screen. But a user which has initiated a call for that shows an error like ERR_CALL_ONGOING_TO_INVALID.

Here is my Accept Call Code.

  var sessionID = "161768871679cd36fa6174a6d10f2----------------------";

            CometChat.acceptCall(sessionID).then(
              call => {
                console.log("Call accepted successfully:", call);
                var sessionId = call.sessionId;
                var callType = call.type;
                var callSettings = new CometChat.CallSettingsBuilder()
                .setSessionID(sessionId)
                .enableDefaultLayout(true)
                .setIsAudioOnlyCall(callType == 'audio' ? true : false)
                .build();
                CometChat.startCall(
                  callSettings,
                  document.getElementById("callScreen"),
                  new CometChat.OngoingCallListener({
                    onUserJoined: user => {
                      /* Notification received here if another user joins the call. */
                      alert('user Joined');
                      console.log("User joined call:", user);
                      /* this method can be use to display message or perform any actions if someone joining the call */
                    },
                    onUserLeft: user => {
                      /* Notification received here if another user left the call. */
                      console.log("User left call:", user);
                      /* this method can be use to display message or perform any actions if someone leaving the call */
                    },
                    onUserListUpdated: userList => {
                      console.log("user list:", userList);
                    },
                    onCallEnded: call => {
                      /* Notification received here if current ongoing call is ended. */
                      console.log("Call ended:", call);
                      /* hiding/closing the call screen can be done here. */
                    },
                    onError: error => {
                      console.log("Error :", error);
                      /* hiding/closing the call screen can be done here. */
                    }
                  })
                  );
                // start the call using the startCall() method
              },
              error => {
                console.log("Call acceptance failed with error", error);
                // handle exception
              }
              );

Hello @rutul,

Just wanted to confirm that you are accepting the call in the onIncomingCallReceived callback right? Also, can you please check if you have CometChat.rejectCall() in your code snippet and somehow that might be getting triggered somehow?

Warm Regards,

CometChat Pro
Mayur Bhandari

No, I am not accepting the call in the onIncomingCallReceived callback.

Hello @rutul,

The flow of calling is as follow,

  • user A initiates a call using CometChat.initiateCall().
  • user B receives the call in the CometChat.CallListener.
  • user B has two options, he/she can either accept the call using CometChat.acceptCall() or reject the call using CometChat.rejectCall().
  • If user B accepts the call, the onOutgoingCallAccepted event will be triggered on user A’s end. Here the user A can start the call using CometChat.startCall(). And user B can start the call in the success of CometChat.acceptCall().
  • If user B rejects the call, the onOutgoingCallRejected event will be triggered on user A’s end.

You can read more about Calling here. You can refer to our React, Angular & Vue UI Kit Sample Apps for reference.

Warm Regards,

CometChat Pro
Mayur Bhandari

Thank you for the given flow.
Is there any working demo or code on Github and any other?

Hello @rutul,

We do have sample apps on GitHub, which you can check out. I am sharing the link to those below.

React: GitHub - cometchat-pro/javascript-react-chat-app: Open-source Voice & Video Calling and Text Chat App for React (JavaScript/Web)
Angular: GitHub - cometchat-pro/javascript-angular-chat-app: Ready-to-use Chat UI Components for Angular (JavaScript/Web)
Vue: GitHub - cometchat-pro/javascript-vue-chat-app: Open-source Voice & Video Calling and Text Chat App for Vue (JavaScript/Web)

Warm Regards,

CometChat Pro
Mayur Bhandari

1 Like

Hello @mayur.bhandari
Thank you for helping.
Can I change the call screen layout regarding my requirement?

Hello @rutul,

I have answered your query regarding Can I change the call screen layout regarding my requirement? on another thread. You can check that thread here.

Warm Regards,

CometChat Pro
Mayur Bhandari

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

Thanks for your sharing. Using video calls on truecaller premium gold software is better.