[asterisk-dev] Asterisk / pjsip: Bug or feature? TCP/TLS connection is endless after unregistering the last trunk to the destination

Joshua C. Colp jcolp at digium.com
Sat Jan 9 04:37:09 CST 2021


On Sat, Jan 9, 2021 at 1:38 AM Michael Maier <m1278468 at mailbox.org> wrote:

>
> Hello!
>
> I'm not sure if the following finding is a bug or a feature. Given is a
> trunk to a registered destination:
>
>
> virtast*CLI> pjsip show registrations
>
>   <Registration/ServerURI..............................>
> <Auth..........>  <Status.......>
>
> ==========================================================================================
>
>   easybellPJSIP/sip:secure.sip.easybell.de                easybellPJSIP
>    Registered
>
> Objects found: 1
>
>
> The related connection:
> # netstat -n | grep 5061
> tcp        0      0 192.168.122.174:58709   212.172.58.207:5061
>  ESTABLISHED
>
> => That's expected.
>
>
> Now doing an unregister
>
> pjsip send unregister *all
>
> gives:
>
> virtast*CLI> pjsip show registrations
>
>   <Registration/ServerURI..............................>
> <Auth..........>  <Status.......>
>
> ==========================================================================================
>
>   easybellPJSIP/sip:secure.sip.easybell.de                easybellPJSIP
>    Unregistered
>
> Objects found: 1
>
> So far so good.
>
>
> But (even after hours - pjsip sends per default tcp/tls keep alives each
> 90 s):
> # netstat -n | grep 5061
> tcp        0      0 192.168.122.174:58709   212.172.58.207:5061
>  ESTABLISHED
>
> => That's not what I expect.
>
> Shouldn't the connection been closed after the last trunk to a destination
> has been closed (there could be more than one numbers / trunks use the same
> destination / connection -
> therefore this would have to be checked before).
>
> What could be the use case to hold the connection forever even if it is
> unused?
>
>
> This behavior can be found with Asterisk 18.x (not tested with 16.x).
>

I believe PJSIP doesn't care or know whether there's anything currently
"active" over the connection, and thus it is kept open for when it may be
used again. To do otherwise and try to be intelligent is likely a ton of
work, which is probably why it was never done. From an Asterisk level we
don't really manage the connections and let PJSIP do it.

-- 
Joshua C. Colp
Asterisk Technical Lead
Sangoma Technologies
Check us out at www.sangoma.com and www.asterisk.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20210109/9eb0c610/attachment.html>


More information about the asterisk-dev mailing list