react-native-pjsip icon indicating copy to clipboard operation
react-native-pjsip copied to clipboard

createAccount iOS not complete registration

Open dariomalfatti-centropaghe opened this issue 4 years ago • 19 comments

On iOs, createAccount not complete the registration. It starts the registration with the SIP server but when the client should send the credentials it stay looked. Account registration stay in 'PJSIP_SC_TRYING' status. Few months ago, it worked like a charm but now, after few Apple update it doesn't and I cannot figure out why.

This is the log from SIP server:

Jun 18 12:40:18 km01 kamailio[32003]: INFO: <script>: Je6XZFKZyQ98W4P6qBkPd9Z4dHCRlkDa|log|from sip:[email protected]
Jun 18 12:40:18 km01 kamailio[32003]: INFO: <script>: Je6XZFKZyQ98W4P6qBkPd9Z4dHCRlkDa|log|to sip:[email protected]
Jun 18 12:40:18 km01 kamailio[32003]: INFO: <script>: Je6XZFKZyQ98W4P6qBkPd9Z4dHCRlkDa|end|challenging [email protected] 123.123.123.123:60935
Jun 18 12:40:18 km01 kamailio[32012]: INFO: <script>: Je6XZFKZyQ98W4P6qBkPd9Z4dHCRlkDa|log|from sip:[email protected]
Jun 18 12:40:18 km01 kamailio[32012]: INFO: <script>: Je6XZFKZyQ98W4P6qBkPd9Z4dHCRlkDa|log|to sip:[email protected]
Jun 18 12:40:18 km01 kamailio[32128]: INFO: <script>: Je6XZFKZyQ98W4P6qBkPd9Z4dHCRlkDa|log|authenticating [email protected] via registrar-4.0.0 response
Jun 18 12:40:18 km01 kamailio[32128]: INFO: <script>: Je6XZFKZyQ98W4P6qBkPd9Z4dHCRlkDa|log|caching sip credentials for [email protected]
Jun 18 12:40:18 km01 kamailio[32128]: INFO: <script>: Je6XZFKZyQ98W4P6qBkPd9Z4dHCRlkDa|end|successful registered with contact : "[email protected]" <sip:[email protected]:60935;app-id=com.centropaghe.viavoip;ob> : 600
Jun 18 12:40:18 km01 kamailio[32005]: INFO: <script>: 2e2f0eba-4ad5-123a-bea6-000c29e2d947|start|received udp request NOTIFY sip:[email protected]
Jun 18 12:40:18 km01 kamailio[32005]: INFO: <script>: 2e2f0eba-4ad5-123a-bea6-000c29e2d947|log|from sip:[email protected]
Jun 18 12:40:18 km01 kamailio[32005]: INFO: <script>: 2e2f0eba-4ad5-123a-bea6-000c29e2d947|log|to sip:[email protected]
Jun 18 12:40:18 km01 kamailio[32001]: INFO: <script>: 2e2f2074-4ad5-123a-3c91-000c29f88e1b|start|received udp request NOTIFY sip:[email protected]
Jun 18 12:40:18 km01 kamailio[32001]: INFO: <script>: 2e2f2074-4ad5-123a-3c91-000c29f88e1b|log|from sip:[email protected]
Jun 18 12:40:18 km01 kamailio[32001]: INFO: <script>: 2e2f2074-4ad5-123a-3c91-000c29f88e1b|log|to sip:[email protected]

Jun 18 12:43:08 km01 kamailio[32011]: INFO: <script>: rDMSVhd8VG6hI6JVITXVQzxD2J6rhMKM|log|from sip:[email protected]
Jun 18 12:43:08 km01 kamailio[32011]: INFO: <script>: rDMSVhd8VG6hI6JVITXVQzxD2J6rhMKM|log|to sip:[email protected]
Jun 18 12:43:08 km01 kamailio[32011]: INFO: <script>: rDMSVhd8VG6hI6JVITXVQzxD2J6rhMKM|end|challenging [email protected] 123.123.123.123:62071

Anybody had this strange behavior?

+1 I'm suffering from the same issue. When I monitored traffic by Wireshark, '401 Unauthorized' message was delivered to my notebook. But, it was not delivered to the iOS App. It seems like the iOS is blocking incoming UDP packets.

bhtak avatar Sep 02 '21 13:09 bhtak

@bhtak To fix it, update the VialerPJSIP.framework in the node_modules/react-native-pjsip with a more updated version.

@dariomalfatti-centropaghe Thank you for the advice. Would you tell me in detail ? Should I replace VialerPJSIP.framework directory with the latest one? Or change react-native-pjsip.podspec file ?

bhtak avatar Sep 02 '21 13:09 bhtak

@bhtak replace the content of VialerPJSIP.framework with the latest one. If I remember well, I copied the content of this inside node_modules/react-native-pjsip/ios/VialerPJSIP.framework and it starts to connecting again. It was very frustating till I found this solution, I waste a lot of time with this. Hope it help.

@dariomalfatti-centropaghe Thank you very much. I'll try.

bhtak avatar Sep 02 '21 14:09 bhtak

@dariomalfatti-centropaghe I did exactly you told and it really works. Thank you so much.

bhtak avatar Sep 03 '21 01:09 bhtak

I have the same problem too. But if I manually copy the folder, the application no longer runs. You can explain me step by step. Use: -RECT Native V0.67.2. -Xcode v13.2.1.

ciaoamigoschat avatar Mar 04 '22 11:03 ciaoamigoschat

You should have this folder and file copyed from this:

node_modules/react-native-pjsip/ios/VialerPJSIP.framework/Headers node_modules/react-native-pjsip/ios/VialerPJSIP.framework/VialerPJSIP

This workend to me but I've a different RN version (0.65.1)

@dariomalfatti-centropaghe I need your help , having the same problem this work on android smoothly but on ios the status remains 'trying'. I tried every thing but not able to register account , i aslo replace the files you asked but its never changes its status please help me . this is my configuartion object : let configuration = { name: 'acoount123', username: sipUserName, domain: sipUserDomain, password: sipUserPassword, proxy: '', transport: 'UDP', // Default TCP regServer: '', // Default wildcard regTimeout: '2592000', // onemonth }; this is my sip start function : const startSipServer = async ( sipUserName: string, sipUserPassword: string, sipUserDomain: string, vopiToken1: any, ) => { // let endpoint = await new Endpoint(); let state = await endpoint.start(configuration); // List of available accounts and calls when RN context is started, could not be empty because Background service is working on Android let {accounts, calls} = state; console.log(accounts); endpoint.on('registration_changed', account => { console.log(account);

});
endpoint.on('connectivity_changed', online => {});
endpoint.on('call_received', call => {
  setIncominingNumber(call._remoteNumber);
  setPressOnDecline(false);
  callType = 'Incomining';
  let callId = call.getId();
  if (callId !== null) {
 
endpoint.on('call_changed', call => {
  console.log(call);
  setPressOnDecline(false);
  console.log(call._stateText);
  callObjectSaveToDb(call);
  setCallObject(call);
  if (call._stateText === 'CALLING') {
    setCallState('Ringing...');
    InCallManager.start({media: 'audio', ringback: '_DTMF_'});
    setCalling(true);
  }      //   console.log('Call changed: ', call);
});
endpoint.on('call_terminated', call => {
  console.log(call);      count = 1;
  hangup();
if (accounts.length === 0) {
  createSipAcc(configuration, vopiToken1);
} else {
  registerSipAcc(accounts[0]);
}

}; These are my logs from xcode v13.2.1 React-native version 0.64.2 12:08:17.091 os_core_unix.c !pjlib 2.8 for POSIX initialized 12:08:17.093 sip_endpoint.c .Creating endpoint instance... 12:08:17.094 pjlib .select() I/O Queue created (0x10b949e28) 12:08:17.094 sip_endpoint.c .Module "mod-msg-print" registered 12:08:17.094 sip_transport.c .Transport manager created. 12:08:17.094 pjsua_core.c .PJSUA state changed: NULL --> CREATED 12:08:17.094 sip_endpoint.c .Module "mod-pjsua-log" registered 12:08:17.094 sip_endpoint.c .Module "mod-tsx-layer" registered 12:08:17.094 sip_endpoint.c .Module "mod-stateful-util" registered 12:08:17.094 sip_endpoint.c .Module "mod-ua" registered 12:08:17.094 sip_endpoint.c .Module "mod-100rel" registered 12:08:17.094 sip_endpoint.c .Module "mod-pjsua" registered 12:08:17.095 sip_endpoint.c .Module "mod-invite" registered 12:08:17.564 coreaudio_dev.c .. dev_id 0: iPhone IO device (in=1, out=1) 8000Hz 12:08:17.564 coreaudio_dev.c ..core audio initialized 12:08:17.566 pjlib ..select() I/O Queue created (0x10f06de28) 12:08:17.567 speex_codec.c ..Adjusting quality to 5 for uwb 12:08:17.569 conference.c ..Creating conference bridge with 12 ports 12:08:17.570 Master/sound ..Using delay buffer with WSOLA. 2022-03-09 12:08:17.604141+0500 FlashLead[1559:600075] [javascript] undetermined 2022-03-09 12:08:17.633487+0500 FlashLead[1559:600075] [javascript] 2022-03-09 12:08:17.637717+0500 FlashLead[1559:600075] [javascript] { item: [Function: item], raw: [Function: raw], length: 0 } 2022-03-09 12:08:17.638007+0500 FlashLead[1559:600075] [javascript] [] 12:08:17.764 transport_srtp.c ..Failed to initialize libsrtp: algorithm failed test routine 12:08:17.764 pjsua_media.c ..Error initializing SRTP library: algorithm failed test routine [status=259810] 2022-03-09 12:08:17.764451+0500 FlashLead[1559:599441] Error in pjsua_init() 12:08:17.764 pjsua_core.c SIP UDP socket reachable at 192.168.11.9:60186 12:08:17.764 udp0x122163430 SIP UDP transport started, published address is 192.168.11.9:60186 12:08:17.764 tcptp:62458 SIP TCP listener ready for incoming connections at 192.168.11.9:62458 12:08:17.765 tlstp:62459 SIP TLS listener is ready for incoming connections at 192.168.11.9:62459 12:08:17.765 pjsua_core.c PJSUA state changed: CREATED --> STARTING 12:08:17.765 sip_endpoint.c .Module "mod-unsolicited-mwi" registered 12:08:17.765 pjsua_core.c .PJSUA state changed: STARTING --> RUNNING 2022-03-09 12:08:17.765963+0500 FlashLead[1559:600075] [javascript] [] 12:08:17.783 pjsua_acc.c Adding account: id=flashlead sip:[email protected] 12:08:17.783 pjsua_acc.c .Account flashlead sip:[email protected] added with id 0 12:08:17.783 pjsua_acc.c .Acc 0: setting registration.. 12:08:17.783 endpoint ..Request msg REGISTER/cseq=13284 (tdta0x10b987ca8) created. 12:08:17.783 tsx0x10b98f4a8 ...Transaction created for Request msg REGISTER/cseq=13285 (tdta0x10b987ca8) 12:08:17.783 tsx0x10b98f4a8 ..Sending Request msg REGISTER/cseq=13285 (tdta0x10b987ca8) in state Null 12:08:17.783 sip_resolve.c ...Target '192.168.1.250:0' type=UDP resolved to '192.168.1.250:5060' type=UDP (UDP transport) 12:08:17.783 pjsua_core.c ...TX 484 bytes Request msg REGISTER/cseq=13285 (tdta0x10b987ca8) to UDP 192.168.1.250:5060: REGISTER sip:192.168.1.250 SIP/2.0

Via: SIP/2.0/UDP 10.212.134.200:60186;rport;branch=z9hG4bKPj-ZhyDHRBBdM6vPtHqrTpXhsewRZiNw4M

Max-Forwards: 70

From: "flashlead" sip:[email protected];tag=URnNe.hAsCVna6zVFg4riv50HGjtDnR8

To: "flashlead" sip:[email protected]

Call-ID: 34O09a6uPrsOBRF5QfqFY-NkOGBPVLYG

CSeq: 13285 REGISTER

Contact: "flashlead" sip:[email protected]:60186;ob

Expires: 2592000

Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO

Content-Length: 0

--end msg-- 12:08:17.783 tsx0x10b98f4a8 ...State changed from Null to Calling, event=TX_MSG 12:08:17.784 pjsua_acc.c ..Acc 0: Registration sent 2022-03-09 12:08:17.784828+0500 FlashLead[1559:600075] [javascript] 'Account created', { _data: { id: 0, domain: '192.168.1.250', password: 'Flash510', registration: { reason: 'test', active: 'test', statusText: 'In Progress', status: 'Trying' }, contactUriParams: null, username: '510', regTimeout: '2592000', regHeaders: null, regContactParams: null, uri: 'flashlead sip:[email protected]', name: 'flashlead', transport: 'UDP', proxy: '', contactParams: null, regServer: '' }, _registration: { _status: 'Trying', _statusText: 'In Progress', _active: 'test', _reason: 'test' } }

abdullahrehan430 avatar Mar 09 '22 04:03 abdullahrehan430

@abdullahrehan430 I think you have always to set the proxy property within the configuration in this way:

proxy: `<sip:${serverSip};transport=${transport.toLowerCase()}>`

Where serverSip should be the ip address of the SIP server and trasport should be udp or tcp

@dariomalfatti-centropaghe tried but same response it never changes. Account created {"_data": {"contactParams": null, "contactUriParams": null, "domain": "192.168.1.250", "id": 0, "name": "flashlead", "password": "Flash510", "proxy": "sip:192.168.0.250;transport=udp", "regContactParams": null, "regHeaders": null, "regServer": "", "regTimeout": "2592000", "registration": {"active": "test", "reason": "test", "status": "Trying", "statusText": "In Progress"}, "transport": "UDP", "uri": "flashlead sip:[email protected]", "username": "510"}, "_registration": {"_active": "test", "_reason": "test", "_status": "Trying", "_statusText": "In Progress"}}

abdullahrehan430 avatar Mar 09 '22 08:03 abdullahrehan430

@abdullahrehan430 in the proxy property you must wrap the value with < > ("<sip:192.168.0.250;transport=udp>"). Can you connect to this sip server with linphone or a softphone you like?

@dariomalfatti-centropaghe
tried this one but no change "proxy": "sip:192.168.0.250;transport=udp" we can connect only with softphone by using this server , in additional I am using forticlient vpn because our server is behind the firewall . Connect with forticlient and simply create a account with given configuration and this is working fine on android but on ios this is not updating the status . I aslo tried zoiper app on ios and this is working fine I have to connect with forticlient and have to give sip credentials on zioper in ios. Can you share with me any project or code for reference. I am testing this on device Iphone xs :Ios 15.1 , is there are any special configuration for ios on xcode ? I successfully created the certificaets for VOIP in developer account or add tick the voip in backgrounds modes. Is we have to add some code on appdelegate.m? I am new to ios development so this are confusions in my mind Thanks for your time in advance.

abdullahrehan430 avatar Mar 09 '22 10:03 abdullahrehan430

If with android works, configuration's parameters are ok. Sorry but I don't have any project to share, I'm not part of pjsip team, I just found a solution with missing registration on iOS that worked to me and I shared it above. Try to check the Vialer within the node_modules/react-native-pjsip/ios folder as descrived above because seems to be the same problem. I did't modify appdelegate.m just follow the README.md of this project

@dariomalfatti-centropaghe first of all i am very thanksful for your time it's really save me . Yes you are right the issue with library. I download the whole Vialer library and from there i copy the files as you described above but the issue is that it contains only the reference of file stored on Git LFS . When i download the file and replace it start like a magic. Very very thanks for your time.

abdullahrehan430 avatar Mar 10 '22 10:03 abdullahrehan430

@abdullahrehan430 I'm realy glad it helped you too! Enjoy!

Hi bro, after i replace file in VialerPJSIP.framework. i got error ios-arm64 when build. So you can help me, how do fix errors. thanks you

the errors:

` Ignoring file ..*/VialerPJSIP.framework/VialerPJSIP, building for iOS-arm64 but attempting to link with file built for unknown-unsupported file format

Showing All Messages Undefined symbol: _pjsua_acc_get_info

Undefined symbol: _pjsip_get_status_text

Undefined symbol: _pjsua_acc_set_registration

Undefined symbol: _pjsua_acc_add

Undefined symbol: _pjsua_vid_dev_get_info

Undefined symbol: _pjsua_vid_enum_wins

Undefined symbol: _pjsua_transport_config_default

Undefined symbol: _pjsua_conf_connect

Undefined symbol: _pjsip_generic_string_hdr_create

Undefined symbol: _pjsua_enum_codecs

Undefined symbol: _pjsua_codec_set_priority

Undefined symbol: _pj_pool_factory_default_policy

Undefined symbol: _pjsua_config_default

Undefined symbol: _pj_caching_pool_init

Undefined symbol: _pj_pool_create

Undefined symbol: _pjsua_call_make_call

Undefined symbol: _pjsua_vid_win_set_size

Undefined symbol: _pjsua_acc_config_default

Undefined symbol: _pjsua_vid_preview_param_default

Undefined symbol: _pjsua_acc_del

Undefined symbol: _pjsua_acc_get_config

Undefined symbol: _pjsua_update_stun_servers

Undefined symbol: _pjsua_set_snd_dev

Undefined symbol: _pjsua_acc_modify

Undefined symbol: _pjsua_logging_config_default

Undefined symbol: _pjsua_media_config_default

Undefined symbol: _pjsua_set_no_snd_dev

Undefined symbol: _pjsua_conf_disconnect

Undefined symbol: _pjsua_init

Undefined symbol: _pjsua_transport_create

Undefined symbol: _pjsip_generic_string_hdr_init2

Undefined symbol: _pj_list_insert_before

Undefined symbol: _pjsua_start

Undefined symbol: _pj_str

Undefined symbol: _pjsua_call_dial_dtmf

Undefined symbol: _pjsua_call_set_hold

Undefined symbol: _pjsua_vid_dev_count

Undefined symbol: _pjsua_call_xfer_replaces

Undefined symbol: _pjsua_call_xfer

Undefined symbol: _pjsua_vid_preview_start

Undefined symbol: _pj_pool_release

Undefined symbol: _pjsua_pool_create

Undefined symbol: _pjsua_call_answer2

Undefined symbol: _pjsua_vid_preview_get_win

Undefined symbol: _pjsua_create

Undefined symbol: _pjsua_call_get_info

Undefined symbol: _pjsua_call_reinvite

Undefined symbol: _pjsua_msg_data_init

Undefined symbol: _pjsua_vid_win_get_info

Undefined symbol: _pjsua_call_setting_default

Undefined symbol: _pjsua_vid_dev_set_setting

Undefined symbol: _pjsua_call_hangup `

utnhim avatar Mar 30 '22 08:03 utnhim

@utnhim hye brother , I think the issue is here you downloaded the wrong library , You should have folder and file copyed from this: node_modules/react-native-pjsip/ios/VialerPJSIP.framework/Headers node_modules/react-native-pjsip/ios/VialerPJSIP.framework/VialerPJSIP

and also make sure on vialerPjsip.framework/VialerPsjip (on github) you have download the file not the referance.

abdullahrehan430 avatar Mar 31 '22 04:03 abdullahrehan430