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

App will crash if you run iOS simulator and reload the app more than 4 times #100

Closed rcorrie closed 6 years ago

rcorrie commented 6 years ago

I think this might be because every time you reload the app via the dev menu, it will register a new account. The app crashes once the max number of accounts has been reached.

datso commented 6 years ago

Hey, yes thats right. Use the state that library returns, and do not create redundant accounts.

basheerkohli commented 6 years ago

max number of accounts for an endpoint is four...remove the accounts..

rcorrie commented 6 years ago

@datso any example on how to detect redundant account and delete it?

@basheerkohli Yes I'm aware of the issue, I'm not sure how to remove the accounts, any ideas on the best practice for persisting the account so that I may delete it on app reload?

In order to use endpoint.deleteAccount you need a reference to the account (which is lost on app reload). Or is there a way to arbitrarily delete all accounts?

datso commented 6 years ago

Hey, once application starts you should retrieve the existing accounts list that returned form endpoint.start promise, and compare it with account you want (e.g. remove account if it is an outdated one or create a new account)

rcorrie commented 6 years ago

@datso that's the part I was missing, thank you!

glocore commented 5 years ago

@rcorrie are you able to delete accounts using deleteAccount(account)? I'm facing this issue when I logout and log back in to my app. It ends up creating duplicate registrations when I log in a second time. As a result, both registrations react to call events.

I tried both deleteAccount(account) as well as registerAccount(account, false), but neither of them worked for me.

Here's how I'm doing it, please let me know if I'm missing something:

  1. Login: const account = await endpoint.createAccount(configuration)
  2. Logout:
    endpoint.registerAccount(account, false);
    endpoint.deleteAccount(account);
  3. Login again: const account = await endpoint.createAccount(configuration) <-- doing this creates a duplicate registration despite having deleted the old account at logout

screenshot 2019-02-18 at 4 59 38 pm

The registration_changed event is fired twice. Notice how both have the same id of 0, which probably means that the old account is indeed getting deleted. Also, I did a packet capture, and the REGISTER request happens only once. But for some reason the registration event inside the library is triggered twice, and subsequently two incoming_call events, etc.