Closed freegor closed 5 years ago
I found exactly same question and a solution on SO: https://stackoverflow.com/questions/46533888/pjsip-crash-on-pj-sockaddr-get-port-when-moving-ios-app-to-background-and-then?rq=1
But I can't find the file _ioqueue_commonabs.c or _replace_udpsock() function in this library, . I think this bug exist for all users.
@freegor Did you get this problem resolved? I struggled for a while. Could you give some hints, thank you.
@Hung-Hsun Yes, I solved it. The incoming call comes from a voip push, you don't need PJSIP to work in the background, so just shutdown the service in the applicationDidEnterBackground method and start it again in the applicationWillEnterForeground or after the voip push about an incoming call.
I use status = pjsua_destroy2(PJSUA_DESTROY_NO_RX_MSG);
function for stop PJSIP.
@freegor Thank you so much for giving this solution, I will try it as soon as possible. Many thanks...
Actually, this should be even easier:
#unset PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT
#define PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT 0
Just configure with these options set.
Hi there,
The library works fine for me. But if a device is in a background mode more then about 60min (I don't know exactly after how much time it begins happens), and I press Home button, I see in app console (see bold text):
--end msg-- 12:27:30.152 pjsua_acc.c ....SIP outbound status for acc 0 is not active 12:27:30.153 pjsua_acc.c ....sip:sip.ХХХХХХХ@ХХХХХХХ:5090: registration success, status=200 (OK), will re-register in 300 seconds 12:27:30.153 pjsua_acc.c ....Keep-alive timer started for acc 0, destination:34.200.47.37:5090, interval:15s
14:01:48.130 ioq_select Attempting to replace UDP socket 6 14:02:06.417 ioq_select Error replacing socket: Invalid argument
After this I let the device go into the background and press Home again, I see:
14:02:15.139 udp0x104134e50 Warning: pj_ioqueue_recvfrom: [err 120009] Bad file descriptor 14:02:15.139 udp0x104134e50 Warning: pj_ioqueue_recvfrom: [err 120009] Bad file descriptor 14:02:15.139 udp0x104134e50 Warning: pj_ioqueue_recvfrom: [err 120009] Bad file descriptor
If I open the app, it crashes with output:
14:05:31.888 pjsua_acc.c Error sending keep-alive packet: Bad file descriptor [status=120009] 2018-01-22 14:05:31.933126+0200 OneCall[686:338791] [] nw_socket_get_input_frames recvmsg(fd 7, 1024 bytes): [57] Socket is not connected 2018-01-22 14:05:31.940869+0200 OneCall[686:362287] dnssd_clientstub write_all(8) DEFUNCT 2018-01-22 14:05:31.940918+0200 OneCall[686:362287] dnssd_clientstub deliver_request ERROR: write_all(8, 57 bytes) failed 2018-01-22 14:05:31.940958+0200 OneCall[686:362287] dnssd_clientstub write_all(8) DEFUNCT 14:05:32.291 pjsua_core.c .TX 547 bytes Request msg REGISTER/cseq=29669 (tdta0x104867600) to UDP 34.200.47.37:5090: REGISTER sip:XXXXXXXXXi:5090 SIP/2.0
Via: SIP/2.0/UDP 81.218.78.4:65506;rport;branch=z9hG4bKPj2YM3brijDW.QXvxrE2gQ03VoH56EUUZc
Max-Forwards: 70
From: sip:sip.XXXXXXX@rXXXXXXX;tag=PnT4O2Z9SEhGW9BYA2NSDHoF3qrHT2am
To: sip:sip.XXXXXXX@XXXXXXXXX
Call-ID: XXXXXXXXXXXXXXXXXXXXXxvcHv
CSeq: 29669 REGISTER
Contact: sip:sip.XXXXXXXXXXX@XXXXXXXXX;ob
Expires: 300
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Content-Length: 0
--end msg-- 14:05:32.291 tsx0x104861ea8 .Failed to send Request msg REGISTER/cseq=29669 (tdta0x104867600)! err=120009 (Bad file descriptor) 14:05:32.291 pjsua_acc.c ...SIP registration failed, status=503 (Bad file descriptor) 14:05:32.291 pjsua_acc.c ...Scheduling re-registration retry for acc 0 in 0 seconds.. 14:05:32.292 sip_reg.c Error sending request, status=120009 Assertion failed: (a->addr.sa_family == PJ_AF_INET || a->addr.sa_family == PJ_AF_INET6), function pj_sockaddr_get_addr, file ../src/pj/sock_common.c, line 314. 2018-01-22 14:07:13.359484+0200 OneCall[686:338778] Task.<7> finished with error - code: -1001
So do you have any idea about it? The app supports only iOS 11.2. I checked it on two devices. Thank you, Igor.
PS I found this issue, it's looks like the same bug: https://www.spinics.net/lists/pjsip/msg20352.html Maybe needed set PJ_ACTIVESOCK_TCP_IPHONE_OS_BG to 0 in pjsip/build/pjproject/src/pjlib/include/pj/compat/os_auto.h? Can you help me? Please.