datso / react-native-pjsip

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

Handle of info message during sipcall #171

Open imanpeeman opened 5 years ago

imanpeeman commented 5 years ago

When te pbx offers an info message during a call, this message should be handled by the client (Dialog in PJSIP terms) when this message isn't handled this causes an '500 Unhandled by dialog usages' response of the client to the PBX. As a result of this 500 response, the PBX terminates the call.

The INFO message is delivered to the java part of react-native-pjsip ( by overriding void onCallTsxState(OnCallTsxStateParam prm) from call.java) but there's no way to return a value to the c part of pjsip.

The PJSIP source code part causing the 500: (sipdialog.c /1720 `if (!processed && tsx && tsx->status_code < 200) { pjsip_tx_data *tdata; const pj_str_t reason = { "Unhandled by dialog usages", 26};

PJ_LOG(4,(tsx->obj_name, "%s was unhandled by "
             "dialog usages, sending 500 response",
             pjsip_rx_data_get_info(rdata)));

status = pjsip_dlg_create_response(dlg, rdata, 500, &reason, &tdata);
if (status == PJ_SUCCESS) {
    status = pjsip_dlg_send_response(dlg, tsx, tdata);
}
}`

The PJSIP logging from the device seeing the INFO message coming in, and the 500 response of the stack.

D/PjSipLogWriter: 16:17:25.247 sip_endpoint.c !Processing incoming message: Request msg INFO/cseq=2 (rdata0xc0986014) D/PjSipLogWriter: 16:17:25.249 pjsua_core.c .RX 591 bytes Request msg INFO/cseq=2 (rdata0xc0986014) from UDP 10.203.143.250:5060: INFO sip:281@10.203.143.147:5060;ob SIP/2.0 Via: SIP/2.0/UDP 10.203.143.250;branch=z9hG4bKa81a.15c57156b2fdd797ad6760ff6fea9909.0 Via: SIP/2.0/UDP 127.0.0.1:5070;branch=z9hG4bK_9_d59018e3_ctxe_00000766_uumid_7d1d6ebb From: "Avond BG 285" sip:285@10.203.143.250;tag=9601DAA3_nab_0055_isp_0055_cco_000F_igo_6358_mgt_FFFF To: sip:281@10.203.143.147;tag=d18574a6-4c6d-4991-b90b-12c80c418ad4 Call-ID: 0202FFFF69FE255C CSeq: 2 INFO Max-Forwards: 69 P-Asserted-Identity: "Avond BG 285" sip:285@10.203.143.250 Privacy: none User-Agent: A5000 R6.4 SP1 /AB00 HOL Content-Length: 0

--end msg--

D/PjSipLogWriter: 16:17:25.251 dlg0xc21ee864 .Received Request msg INFO/cseq=2 (rdata0xc0986014) D/PjSipLogWriter: 16:17:25.252 tsx0xc1369064 ...Transaction created for Request msg INFO/cseq=2 (rdata0xc0986014) D/PjSipLogWriter: 16:17:25.253 tsx0xc1369064 ..Incoming Request msg INFO/cseq=2 (rdata0xc0986014) in state Null D/PjSipLogWriter: 16:17:25.255 tsx0xc1369064 ...State changed from Null to Trying, event=RX_MSG D/PjSipLogWriter: 16:17:25.256 dlg0xc21ee864 ....Transaction tsx0xc1369064 state changed to Trying D/PjSipCall: XXXX onCallTsxState type: PJSIP_EVENT_TSX_STATE D/PjSipCall: XXXX onCallTsxState statuscode A: 0 D/PjSipCall: XXXX onCallTsxState statuscode B: 200 D/PjSipLogWriter: 16:17:25.260 tsx0xc1369064 ..Request msg INFO/cseq=2 (rdata0xc0986014) was unhandled by dialog usages, sending 500 response D/PjSipLogWriter: 16:17:25.262 endpoint ..Response msg 500/INFO/cseq=2 (tdta0xdc17c064) created D/PjSipLogWriter: 16:17:25.263 dlg0xc21ee864 ...Sending Response msg 500/INFO/cseq=2 (tdta0xdc17c064) D/PjSipLogWriter: 16:17:25.264 tsx0xc1369064 ...Sending Response msg 500/INFO/cseq=2 (tdta0xdc17c064) in state Trying D/PjSipLogWriter: 16:17:25.266 sip_resolve.c ....Target '10.203.143.250:5060' type=UDP resolved to '10.203.143.250:5060' type=UDP (UDP transport) D/PjSipLogWriter: 16:17:25.267 pjsua_core.c ....TX 478 bytes Response msg 500/INFO/cseq=2 (tdta0xdc17c064) to UDP 10.203.143.250:5060: SIP/2.0 500 Unhandled by dialog usages Via: SIP/2.0/UDP 10.203.143.250;received=10.203.143.250;branch=z9hG4bKa81a.15c57156b2fdd797ad6760ff6fea9909.0 Via: SIP/2.0/UDP 127.0.0.1:5070;branch=z9hG4bK_9_d59018e3_ctxe_00000766_uumid_7d1d6ebb Call-ID: 0202FFFF69FE255C From: "Avond BG 285" sip:285@10.203.143.250;tag=9601DAA3_nab_0055_isp_0055_cco_000F_igo_6358_mgt_FFFF To: sip:281@10.203.143.147;tag=d18574a6-4c6d-4991-b90b-12c80c418ad4 CSeq: 2 INFO Content-Length: 0

--end msg--

D/PjSipLogWriter: 16:17:25.269 tsx0xc1369064 ....State changed from Trying to Completed, event=TX_MSG D/PjSipLogWriter: 16:17:25.270 dlg0xc21ee864 .....Transaction tsx0xc1369064 state changed to Completed D/PjSipCall: XXXX onCallTsxState type: PJSIP_EVENT_TSX_STATE D/PjSipCall: XXXX onCallTsxState statuscode A: 500 D/PjSipCall: XXXX onCallTsxState statuscode B: 200'

we've tried to adapt the statuscode so it will be returned to the c part of the code, but this doesn't fix the issue.

Is there a way to pass a response code back to the PBX?

Thanks in advance!

datso commented 5 years ago

I would suggest to ask on pjsip mailing list. I haven't seen such issue before with INFO messages, might be a full sip trace could help me understand why pjsip respond with 500.