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

Account is not creating after deleting any other account. #147

Open basheerkohli opened 5 years ago

basheerkohli commented 5 years ago

Hey Datso,

My application is like creating an account every time when i want to make a call. What happening is account is creating for the first time and call functionality is fine when i hangup call everything seems perfect, but for the next turn when am calling await endpoint.createaccount(confg) the promise is neiter resolving nor rejecting. I tested same scenario without deleting the account other time but then the accounts are creating then. Please help me out of this it been blocker for me.

Thanks

basheerkohli commented 5 years ago

This case happening in the android application development.

rodrigowbazevedo commented 5 years ago

Having the same issue

mdiflorio commented 5 years ago

Why do you need to create and delete accounts so often?

Why don't you just create the account or update its credentials if needed and make calls using the one account?

That being said, you shouldn't have issues deleting and creating accounts. Within my app, I do exactly that when a user logs out and back in.

rodrigowbazevedo commented 5 years ago

Why do you need to create and delete accounts so often?

Why don't you just create the account or update its credentials if needed and make calls using the one account?

That being said, you shouldn't have issues deleting and creating accounts. Within my app, I do exactly that when a user logs out and back in.

I create dynamic accounts so after use it once it becomes invalid and I don't need it anymore, this issue happens if you use de deleteAccount() method, but it won't if you use registerAccount(account, false) method to unregister.

I didn't test yet to delete the account after unregister it.

mobdim commented 5 years ago

I have the same issue.

glocore commented 5 years ago

Any updates on this? This is a serious issue when using push notifications to receive calls. The problem is that when I use either of the deleteAccount() or registerAccount(account, false) methods, re-registering creates another duplicate registration on top of the old one. This causes both the registrations to respond to call events simultaneously.

That being said, you shouldn't have issues deleting and creating accounts. Within my app, I do exactly that when a user logs out and back in.

@mierz00 how exactly are you deleting the account?

glocore commented 5 years ago

@rodrigowbazevedo I wasn't able to get it to work with either of the methods, how do you prevent duplicate account registrations?

rodrigowbazevedo commented 5 years ago

@rodrigowbazevedo I wasn't able to get it to work with either of the methods, how do you prevent duplicate account registrations?

My application get the account credentials from the backend after login, my backend always return a unique new account, after logout I unregister the account using registerAccount(account, false), it's working for me.

glocore commented 5 years ago

@rodrigowbazevedo Thanks for your response! What do you do to register after you log back in? Do you use createAccount() to generate a new account? Because that's where I'm facing the issue of duplicate registrations.

glocore commented 5 years ago

I've added more details here, if that helps.

yunhanxia commented 5 years ago

Same issue, I'm crashing when I try to createAccount after registerAccount(account, false) and deleteAccount(account), I'm trying to do Login and Logout

rohitvc commented 4 years ago

@basheerkohli did you managed to solve the issue. I am facing the same issue as well. After creating 4 accounts, i am getting this error

error register : Title: pjsua_acc_add(&pj_acc_cfg, make_default, &id) Code: 70010 Description: Too many objects of the specified type (PJ_ETOOMANY) Location: ../src/pjsua2/account.cpp:733

This problem mainly occurs, where we allow users to manually enter the configuration details (domain, password, proxy, transport etc) for registration and even if they enter incorrect credentials and submit the request to endpoint.createaccount() is considered and after 4 requests i am getting above error.

To prevent this i have done following :- 1) If user tries to send same data repeatedly, i am calling endpoint.registerAccount(account, true) on that account so that the 4 request limit is not reached.'

2) I am keeping check on the accounts created on endpoint and if Number of accounts are more than 1, i am deleting the 1st account in the array returned by endpoint state using endpoint.deleteAccount(account). This works properly in some cases, but most of the time when i try to register another account after delete, the app crashes with following error log

2019-11-08 19:29:04.732 21628-21706/com.ivy_mobile D/PjSipLogWriter: 19:29:04.732            
pjsua_acc.c  .Acc 1: setting registration..

    --------- beginning of crash
2019-11-08 19:29:04.735 21628-21706/com.ivy_mobile A/libc: FORTIFY: pthread_mutex_lock called on a destroyed mutex (0x75d91088a8)
2019-11-08 19:29:04.775 21628-21706/com.ivy_mobile A/libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 21706 (PjSipService), pid 21628 (com.ivy_mobile)

Can someone please help how to handle the delete and create accounts more gracefully without crash so that the limit is not exceeded ? Any suggestions @rodrigowbazevedo @mierz00 @glocore @datso