Ticket #1990 (closed defect: fixed)
Call fails to answer due to ICE media transport init blocking
|Reported by:||nanang||Owned by:||bennylp|
|Backport to 1.x milestone:||Backported:||no|
pjsua_call.c Answering call 1: code=200 pjsua_call.c Pending answering call 1 upon completion of media transport ... pjsua_call.c Answering call 1: code=200 pjsua_call.c Pending answering call 1 upon completion of media transport ... (and so on)
After investigation, the blocking part turns out to be TURN allocation which seems to take forever.
- DNS resolver is configured and the TURN server hostname is in the DNS resolver cache
- ICE is trying to create TURN candidate, it creates TURN transport and starts TURN allocation by invoking pj_turn_sock_alloc()
- pj_turn_session_set_server() starts resolving TURN server IP address by invoking pj_dns_srv_resolve()
- as DNS entry is in the cache, DNS resolver callback is invoked in the same context which triggers TURN allocation
- the TURN allocation fails synchronously too, so TURN transport destroys itself, DNS resolver callback returns, and then pj_dns_srv_resolve() also returns with PJ_SUCCESS return value as the resolution was successful
- alas, the PJ_SUCCESS return value is propagated upstream, so ICE sees that pj_turn_sock_alloc() returns PJ_SUCCESS and TURN candidate is added
- as the failure happens prematurely before TURN candidate is added, the candidate status remains PJ_EPENDING forever.
The idea is to add check for possibility of premature failure in pj_turn_sock_alloc() after pj_turn_session_set_server() returns PJ_SUCCESS.
Thanks Bing Huan Chio for the report.