datso / react-native-pjsip

A PJSIP module for React Native.
http://datso.github.io/react-native-pjsip
GNU General Public License v3.0
272 stars 229 forks source link

Android: endpoint.on('registration_changed', account => {}) is throwing PJSIP_SC_BAD_GATEWAY error #160

Closed krajay015 closed 5 years ago

krajay015 commented 5 years ago

I'm using react-native-pjsip library for my project and in iOS, everything seems to work perfectly but in android it's throwing following error on createAccount method. I'm attaching my code here to make it more visible. start the endpoint :

async (dispatch: Function, getState: Function) => {
    const endpoint = new Endpoint();
    const state = await endpoint.start({
      service: {
        ua: 'RN SIP',
      },
      network: {
        useWifi: true,
        useOtherNetworks: true,
      },
    });

after that creating account via using createAccount method:

endpoint.createAccount({
       name, username, domain, password
      }).then(acnt => {
        console.log(acnt); //metion response below
      })
        .catch(error => {
          console.log(error);
        })

and in response I'm getting :

{
    "_data ": {
        "registration ": {
            "reason ": "gethostbyname() has returned error(PJ_ERESOLVE)",
            "statusText ": "Bad Gateway ",
            "active ": false,
            "status ": "PJSIP_SC_BAD_GATEWAY "
        },
        "regOnAdd ": true,
        "regTimeout ": "600 ",
        "password ": " ** ** ** ** ** ** ** ",
        "domain ": " ** * . ** * . ** . ** ",
        "name ": "Ajay ",
        "username ": "ajay - device ",
        "uri ": "Ajay < sip: ajay - device @ ** * . ** * . ** . ** > ",
        "id ": 1
    },
    "_registration ": {
        "_status ": "PJSIP_SC_BAD_GATEWAY ",
        "_statusText ": "Bad Gateway ",
        "_active ": false,
        "_reason ": "gethostbyname() has returned error(PJ_ERESOLVE)"
    }
}

The same thing is working perfectly on iPhone emulator.

@cmendes0101 @aronStein @pazualo @tophed can you help me, guys?

pazualo commented 5 years ago

@krajay015 I can't see anything wrong in your code, but you mentioned that the console returned was from the callback and not from the catch block console. I would recommend you to make sure and debug your params you're sending to pjsip. I mean if it sends you this type of response it should be working if the values you supplied are correct. I can recommend you to contact your SIP service (cloud or else), that's how I made it work

endpoint.createAccount({ name, username, domain, password }).then(acnt => { console.log(acnt); //metion response below }) .catch(error => { console.log(error); })

ReactNDev commented 2 years ago

@pazualo Can you please help me finding the issue in my code ? Actually I'm also getting the same issue. Actually I have server URL, username and password and I want to createAccount but always getting this error -

"_registration": {"_active": false, "_reason": undefined, "_status": "PJSIP_SC_TRYING", "_statusText": "In Progress"}

let configuration = {} configuration.username = 'xxxxxx'; configuration.domain = 'sip.xxxxx.com'; configuration.password = "xxxxxxxx"; configuration.transport = "WSS", configuration.regServer = 'wss://xxxxxxx/ws', configuration.regTimeout = null, configuration.regHeaders = { "X-Custom-Header": "Value" }, configuration.regContactParams = ";unique-device-token-id=XXXXXXXXX" console.log(configuration)

await endpoint.createAccount(configuration) .then((returnAcc) => { console.log("-------", returnAcc); this.setState({ account: returnAcc }); }).catch((e) => { console.log("Error", e); });