[pjsip] Passing SIP through TURN

Benny Prijono bennylp at teluu.com
Wed Jun 6 22:48:21 EDT 2012

On Thu, Jun 7, 2012 at 2:38 AM, Guilherme Balena Versiani
<guibv at nymgo.com>wrote:

> Hello,
> My idea is basically pass the SIP traffic through a TURN server to
> overcome some firewall limitations.
> I'm using PJSUA, registering an UDP transport using pjsua_transport_create
> as usual, and, when I discover a timeout 408 during the first REGISTER, my
> idea was to close the previously created UDP transport and register a new
> one. I've implemented a sip_transport_turn.c based on the
> sip_transport_udp.c, and during the initialization it sends an allocate
> request to TURN to listen to SIP packets. In the on_rx_data callback, I am
> checking if this is the first time I am sending packets to this
> destination, and, if so, I'm using the pj_turn_sock_set_perm to add
> permission to send data.
> Everything is great in theory, but I am facing a lot of problems in PJSUA
> code (I'm using PJSIP 2.0):
>     1 - I'm trying to close the UDP transport in the on_reg_state callback
> from pjsua_acc, using the function pjsua_transport_close;
>     1.1 - If I try to pass PJ_TRUE to force the destruction of the UDP
> transport, there is an assertion error being thrown
> in pjsip_transport_destroy:
>         PJ_ASSERT_RETURN(pj_atomic_get(tp->ref_cnt) == 0, PJSIP_EBUSY);
Just to clarify, you are trying to close UDP SIP transport, not your TURN
UDP SIP transport, right? The force=TRUE option, I'm afraid is not working.
You should use FALSE and let pjsip destroy the transport once the reference
counter is zero.

>     1.2 - If I try to pass PJ_FALSE, then the UDP transport is smoothly
> destroyed after a while, but in this case PJSUA maintains an invalid
> pointer in pjsua_var structure (specifically in tpdata member).
This shouldn't happen unless the transport is destroyed prematurely.

Best regards

As there is no examples of real use case scenarios using PJNATH and SIP
> together, I'm clueless.
> Regards,
> Guilherme Balena Versiani.
> _______________________________________________
> Visit our blog: http://blog.pjsip.org
> pjsip mailing list
> pjsip at lists.pjsip.org
> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20120607/64c90302/attachment.html>

More information about the pjsip mailing list