[pjsip] Multiple transports

Benny Prijono bennylp at pjsip.org
Thu Nov 22 22:59:50 EST 2007

logan wrote:
> Hello Benny,
> I use multiple UDP transports in my application. One is used for accounts 
> which are on public Internet and other for the local proxy (both transports 
> use different SIP ports).
> We saw one weird issue, the REGISTER request is always send from the port 
> which was created at the last (I guess pjsua_create_transport makes the 
> created transport the default one). Because of this the originating UDP port 

Yes this is pjsip's behavior. The latest UDP transport will
overwrite the previously registered transport in the transport hash
table, so it will be used as the default transport.

> is different from the one mentioned in via and contact headers. All other 
> requests like INVITE, CANCEL, BYE, etc are send from the correct port, with 
> the correct port mentioned in the other headers. The problem seemed to be 
> with REGISTER requests only. After some digging into the library it seems to 
> me that the REGISTER transactions are not using the correct transport. I 
> added the following code to \pjsip\sip_util_statefull.c, inside the function 
> pjsip_endpt_send_request, around line number 105:
> if (timeout == REGC_TSX_TIMEOUT)
> {
>     pjsip_regc *regc = (pjsip_regc *)token;
>     if (regc)
>     {
>         pjsip_tsx_set_transport (tsx, &regc->tp_sel);
>     }
> }
> This seems to have solved the problem as we now set the transport to be used 
> explicitly, after making the check that the transaction is for a REGISTER 
> request, and the requests are now send from the correct port. But, I'm not 
> sure if this is a solution or just a temporary fix. Can you please shed some 
> light?

I think you're right, turns out that regc doesn't make use of the
transport selector/tp_sel when sending the outgoing REGISTER, hence
the default transport will be used!

I've committed a fix for this in
http://www.pjsip.org/trac/ticket/423. Basically, in sip_reg.c, in
function pjsip_regc_send() line 838, before calling
pjsip_endpt_send_request(), add these lines:

     /* Bind to transport selector */
     pjsip_tx_data_set_transport(tdata, &regc->tp_sel);

Then in \pjsip\sip_util_statefull.c, inside the function
pjsip_endpt_send_request(), line number 105:

     pjsip_tsx_set_transport(tsx, &tdata->tp_sel);

I think that should fix it. Thanks for the report!


> Thanks.
> Best Regards,
> Hitesh

More information about the pjsip mailing list