datso / react-native-pjsip

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

Account state is always false #231

Closed talhafiaz09 closed 3 years ago

talhafiaz09 commented 3 years ago

Every time I try to connect to my SIP server it gives me active false. I tried using a VPN but still, it shows me the same response. Can anyone please guide me or if someone has used this library then please help me? This is a snippet of the response I get: Screenshot 2021-02-09 172311

subiyantoro commented 3 years ago

yeah, me stuck on this too. i hope author can help us

talhafiaz09 commented 3 years ago

@subiyantoro i have solved this issue

talhafiaz09 commented 3 years ago

i can share my config with you the problem was in configuration. let state = await endpoint.start(); let {accounts, calls, settings, connectivity} = state; endpoint.on('registration_changed', (account) => { if (account._registration._active) { setAccount(account); console.log('Registration changed: ', account); } }); endpoint.on('connectivity_changed', (online) => { console.log('Connectivity changed: ', online); }); endpoint.on('call_received', (call) => { console.log('Call received: ', call); }); endpoint.on('call_changed', (call) => { console.log('Call changed: ', call); }); endpoint.on('call_terminated', (call) => { console.log('Terminated: ', call); }); let configuration = { name: 'retail', username: 'xyzzz', domain: '194.28.167.180', password: '***', proxy: 'sip:194.28.167.180:5060', // default disabled. transport: 'UDP', // default TCP regServer: null, // default taken from domain regTimeout: 1000, // default 300 }; endpoint .createAccount(configuration) .then((account) => {}) .catch((e) => { console.log(e); });

Do it like this and wait until your account status changes. You may need a VPN as in my case sip calling is not allowed in my country. :)

subiyantoro commented 3 years ago

it's work, thanks @talhafiaz09 , do you mind to share the function setAccount code

talhafiaz09 commented 3 years ago

@subiyantoro there is no such function setAccount in pjsip

syeda-sumreen-ali commented 3 years ago

hello this is my code and I'm facing the same issue how can I resolve ?

import React from 'react' import { StyleSheet, Text, View } from 'react-native' import { Endpoint } from 'react-native-pjsip'

const App = async () => { let endpoint = new Endpoint(); let state = await endpoint.start(); let { accounts, calls, settings, connectivity } = state; endpoint.on('registration_changed', (account) => { if (account._registration._active) { setAccount(account); console.log('Registration changed: ', account); } }); endpoint.on('connectivity_changed', (online) => { console.log('Connectivity changed: ', online); }); endpoint.on('call_received', (call) => { console.log('Call received: ', call); }); endpoint.on('call_changed', (call) => { console.log('Call changed: ', call); }); endpoint.on('call_terminated', (call) => { console.log('Terminated: ', call); }); let configuration = { "name": "101", "username": "101", "domain": "pbx.trendsjo.com", "password": "sa1234qq", "proxy": null, "transport": "WSS", // Default TCP "regServer": "wss://pbx.trendsjo.com:8089", // Default wildcard "regTimeout": 1000, // Default 3600 "regHeaders": { "X-Custom-Header": "Value" }, "regContactParams": ";unique-device-token-id=XXXXXXXXX" }; endpoint .createAccount(configuration) .then((account) => { console.log("ACCOUNT CREATED:", account) }) .catch((e) => { console.log(e); }); return (

SIP TESTING

) }

export default App

const styles = StyleSheet.create({})

talhafiaz09 commented 3 years ago

@syeda-sumreen-ali let me check your code snippet

talhafiaz09 commented 3 years ago

@syeda-sumreen-ali please reconfirm that is your configurations valid and the also please recheck the port you are assigning

ReactNDev commented 2 years ago

@talhafiaz09 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 account state false.

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);
  });
talhafiaz09 commented 2 years ago

@talhafiaz09 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 account state false.

let configuration = {}

configuration.username = 'xxxxxx';

configuration.domain = 'sip.xxxxx.com';

configuration.password = "xxxxxxxx";

configuration.transport = "WSS",

configuration.regServer = 'wss://xxxxxxxws',

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);

  });

yes brother i can help you as soon as possible and will share it with you

ReactNDev commented 2 years ago

Hi @talhafiaz09 Any update ?? Thanks in advance!