Why i am not receiving call in Voximplant?

136 Views Asked by At

I am trying to receive an incoming call from a user who is calling me but I am not getting any call from that user on the user side it's giving an error message that Cal Failed Reason: Not Found I am using Voximplant react native i have both the users in my voximplant control panel but still this problem is coming

I set up my code that way first it hit an API and if it gives the message "Ok" then it will only login and user and listing for incoming calls what is the problem with my code?

import { Voximplant } from 'react-native-voximplant';
import calls from './store';
import { VOXIMPLANT_APP, VOXIMPLANT_ACCOUNT } from '../Constants/voximplant';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { Platform } from 'react-native';

export const initVoximplant = (navigation) => {
  const login = async () => {
    try {
      const voximplant = Voximplant.getInstance();
      const userDataString = await AsyncStorage.getItem('user');
      const e = await JSON.parse(userDataString!);
      const clientState = await voximplant.getClientState();

      if (clientState === Voximplant.ClientState.DISCONNECTED) {
        await voximplant.connect();
        await voximplant.login(
          `${e.user._id}@${VOXIMPLANT_APP}.${VOXIMPLANT_ACCOUNT}.voximplant.com`,
          e.user._id,
        );
      }
      if (clientState === Voximplant.ClientState.CONNECTED) {
        await voximplant.login(
          `${e.user._id}@${VOXIMPLANT_APP}.${VOXIMPLANT_ACCOUNT}.voximplant.com`,
          e.user._id,
        );
      }
    } catch (e) {
      console.log("Error is je", e)
      let message = 'Unknown error. Try again';
      if (e.name === Voximplant.ClientEvents.ConnectionFailed) {
        message = 'Connection error, check your internet connection';
      }
    }
  };

  const a = Platform.OS === 'ios' ? 'http://localhost:3000' : 'http://10.0.2.2:3000';
  const checkUserNotifee = async () => {
    try {
      const userDataString = await AsyncStorage.getItem('user');
      const e = await JSON.parse(userDataString!);
      const voximplant = Voximplant.getInstance();
      const response = await fetch(`${a}/notifeeuser`, {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
        },
        body: JSON.stringify({
          user: e.user._id
        }),
      });
      const data = await response.json();
      if (data.message === 'Ok') {
        login()
        voximplant.on(Voximplant.ClientEvents.IncomingCall, (incomingCallEvent) => {
          calls.set(incomingCallEvent.call.callId, incomingCallEvent.call);
          console.log(incomingCallEvent.call.callId, incomingCallEvent.call)
          navigation.navigate('IncomingCall', {
            callId: incomingCallEvent.call.callId,
          });
        });
        return function cleanup() {
          voximplant.off(Voximplant.ClientEvents.IncomingCall);
        };
      } 
    } catch (error) {
      console.log(error);
    }
  };
  checkUserNotifee();
};
1

There are 1 best solutions below

1
On

The call fail error "Not Found" means that there is an issue with your setup in the Voximplant Control Panel.

You need to check:

  1. You have both users (caller and callee) in your Voximplant application in the Voximplant Control Panel and you can successfully login both these users.
  2. You have a VoxEngine scenario in your Voximplant application.
  3. You have set up a routing rule in your Voximplant application. I recommend to use .* pattern for the rule, so all usernames match the rule.

If everything is ok, I recommend you check what exactly is passed as the "number" parameter to the Client.call API on the caller side.

If you use one of these scenarios, you should check that you pass the username of the callee to the Client.call API on the caller side.

Let's assume you have 2 users:

To make a call from user1 to user2 (with previously completed setup in the Voximplant Control Panel):

const voximplant = Voximplant.getInstance();
// connect and login user1

const callSettings = {
  video: {
    sendVideo: isVideoCall,
    receiveVideo: isVideoCall,
  },
};

let call = await voximplant.call("user2", callSettings);
// setup call listeners

Regarding your code snippet, I don't see any issues related to Voximplant React Native SDK API. However, I recommend to add await for login() method call:

const data = await response.json();
if (data.message === 'Ok') {
  await login();
  // .....
}