[Home]

Summary:ASTERISK-16279: [patch] TCP connection will not be closed, if device do a reregister
Reporter:Marcello Ceschia (marcelloceschia)Labels:
Date Opened:2010-06-22 07:12:18Date Closed:2011-05-05 13:09:25
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Channels/chan_sip/TCP-TLS
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) chan_sip-close-tcp-connection.patch
( 1) chan_sip-tcp-close_branch162.patch
( 2) chan_sip-tcp-close_branch18.patch
( 3) tcptls.patch
Description:If I use a mobile device that switches between 3G an WLAN, several tcp ports stay open.
Only a unregister from the client does close the ports, "sip unregister <peer>" does not.



****** ADDITIONAL INFORMATION ******

E.g.:

*CLI> sip show tcp
Host                           Port Transport   Type
172.17.1.50                    40039  TCP       Server
172.17.1.50                    59966  TCP       Server


# netstat -n | grep "5060"
tcp        0      0 172.17.3.1:5060         172.17.1.50:59966       VERBUNDEN  
tcp        0      0 172.17.3.1:5060         172.17.1.50:40039       VERBUNDEN  
tcp        0      0 172.17.3.1:5060         172.17.1.50:50794       VERBUNDEN
Comments:By: Stefan Tichy (st) 2010-07-20 10:17:52

Since Asterisk leaves TCP connections open the KEEPALIVE socket option may help
(tcptls.patch)

By: Marcello Ceschia (marcelloceschia) 2010-08-04 12:10:27

I think, asterisk should check if there is already a tcp connection on this peer.

By: Marcello Ceschia (marcelloceschia) 2010-08-08 12:05:14

I added two patches for asterisk 1.6.2 and 1.8
The patch checks if there is already a open tcp connection for this peer, if there is one it will close this connection and continues with the new one.
Also added socket option patched by st.



By: Marcello Ceschia (marcelloceschia) 2010-08-10 13:30:23

can we change to state: "ready for review"?



By: Diederik de Groot (dkgroot) 2010-09-06 08:28:52

Thanks Marcello,

I have tested it and it seems to work pretty well for me. The connections are closed on re-register.

Regards,

D.

By: Marcello Ceschia (marcelloceschia) 2010-10-08 01:11:18

No response for this?

By: Marcello Ceschia (marcelloceschia) 2011-05-02 11:46:11

I added a new version for asterisk 1.8, because i missed to decrement th reference

By: Matthew Nicholson (mnicholson) 2011-05-05 12:49:42

I am going to commit a modified version the TCP KEEPALIVE fix for this issue.  I am not sure closing the existing session for that peer is the right way to handle this.

By: Digium Subversion (svnbot) 2011-05-05 12:59:15

Repository: asterisk
Revision: 317195

U   branches/1.6.2/channels/chan_sip.c

------------------------------------------------------------------------
r317195 | mnicholson | 2011-05-05 12:59:14 -0500 (Thu, 05 May 2011) | 8 lines

Set SO_KEEPALIVE on SIP TCP sockets so that they eventually go away when a peer
abruptly disappears.  This mostly occurs after a successful registration.

(closes issue ASTERISK-16279)
Reported by: marcelloceschia
Patches:
     (modified) tcptls.patch uploaded by st (license 907)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=317195

By: Digium Subversion (svnbot) 2011-05-05 13:02:54

Repository: asterisk
Revision: 317196

U   branches/1.8/channels/chan_sip.c

------------------------------------------------------------------------
r317196 | mnicholson | 2011-05-05 13:02:53 -0500 (Thu, 05 May 2011) | 8 lines

Set SO_KEEPALIVE on SIP TCP sockets so that they eventually go away when a peer
abruptly disappears.  This mostly occurs after a successful registration.

(closes issue ASTERISK-16279)
Reported by: marcelloceschia
Patches:
     (modified) tcptls.patch uploaded by st (license 907)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=317196

By: Digium Subversion (svnbot) 2011-05-05 13:09:24

Repository: asterisk
Revision: 317198

_U  trunk/
U   trunk/channels/chan_sip.c

------------------------------------------------------------------------
r317198 | mnicholson | 2011-05-05 13:09:24 -0500 (Thu, 05 May 2011) | 15 lines

Merged revisions 317196 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
 r317196 | mnicholson | 2011-05-05 13:02:52 -0500 (Thu, 05 May 2011) | 8 lines
 
 Set SO_KEEPALIVE on SIP TCP sockets so that they eventually go away when a peer
 abruptly disappears.  This mostly occurs after a successful registration.
 
 (closes issue ASTERISK-16279)
 Reported by: marcelloceschia
 Patches:
       (modified) tcptls.patch uploaded by st (license 907)
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=317198

By: Andrea Cristofanini (hydrolife) 2011-07-12 05:41:41.035-0500

Hi there, using Asterisk 1.8 version this patch looks not work properly.

I use a TCP TLS mobile client for test is, registering the client using wifi then closing wifi connection and swapping to GSM, there are many TCP connection that stay up into the system.

sip  show  tcp
Address                                         Transport   Type
192.168.11.176:50927                            TLS       Server
192.168.11.176:50945                            TLS       Server
192.168.11.176:50952                            TLS       Server
192.168.11.176:50966                            TLS       Server
192.168.11.176:50982                            TLS       Server
192.168.11.176:50990                            TLS       Server
192.168.11.176:50996                            TLS       Server
192.168.11.176:51018                            TLS       Server
192.168.11.176:51036                            TLS       Server

netstat -na | grep 5061  -wc
10


Any ideas??

Regards



By: Andrea Cristofanini (hydrolife) 2015-01-21 20:23:37.033-0600

Hi there,
are there any news regarding this bugs???

Andrea

By: Matt Jordan (mjordan) 2015-01-22 08:15:01.827-0600

This issue is closed.

If you feel this is still a problem, you will need to open a new issue. Please provide:
* Your {{sip.conf}}
* A debug log with 'sip set debug on' illustrating the problem. Indicate in the issue report where the problem occurs in the log. Instructions can be found on the Asterisk wiki on how to properly generate a debug log: https://wiki.asterisk.org/wiki/display/AST/Collecting+Debug+Information
* Evidence showing the persistent TCP connection.