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

can not connect to the sip server #126

Open Husseinoj opened 6 years ago

Husseinoj commented 6 years ago

I'm trying to connect to the sip server. the way i passed is installing react-native-pjsip and added the android setting like permission, ... in android folder and in javascript i did like this: import {Endpoint} from 'react-native-pjsip'; var endpoint = new Endpoint(); let configuration = { "name": "username", "username": "username", "domain": "sip:ServerIp", "password": "password", "proxy": null, "transport": "UDP", // Default TCP "regServer": "sip:ServerIp:5060", // Default wildcard "regTimeout": 3000, // Default 3600 "regHeaders": { "X-Custom-Header": "Value" } }; and simply trying to start and Login to server like this // let endpoint = new Endpoint(); console.log("JSON Result is ==>"+JSON.stringify(endpoint)); const state = await endpoint.start();

console.log(+JSON.stringify(state));
let {accounts, calls} = state;
console.log("JSON is==> "+JSON.stringify(accounts));
endpoint.createAccount(configuration).then((account) => {
  console.log("Account created", account);
}).catch((error)=>{
   console.log("Error:" +error);
});

but i get the following error

JSON Result is ==>{"_events":{}} D:\Practice\sipapp\App.js:56 NaN D:\Practice\sipapp\App.js:58 JSON is==> [] D:\Practice\sipapp\App.js:62 Error:Title: pjsua_acc_add(&pj_acc_cfg, make_default, &id) Code: 171039 Description: Invalid URI (PJSIP_EINVALIDURI) Location: ../src/pjsua2/account.cpp:733

and the whole thing that i did is here https://paste.ofcode.org/Q3TyUtcT3xEZMdH53RtnN5

tophed commented 5 years ago

I think your problem may be in your configuration object - for domain you should just put the server IP without the 'sip:' prefix.