[OpenSIPS-Devel] TCP connection behavior
Răzvan Crainea
razvan at opensips.org
Tue May 21 08:30:40 EDT 2019
Hi, Dan!
This is the intended behavior, since OpenSIPS 1.8 (or 1.11, can't
remember for sure).
In order to avoid moving TCP connections from one process to the other
answer, when data is sent to a TCP connection, that connection is moved
to a TCP worker and is kept by that process for a while. It is only
moved back to the main if the connection is idle.
Regarding the file descriptors, it is normal to have different values in
different processes, as each process has its own file descriptors table.
Best regards,
Răzvan
On 5/21/19 2:55 PM, Dan Pascu wrote:
>
> I noticed TCP connections behave differently now. Not sure if it's intentional or a problem.
>
> Before, all TCP connections were hold by the TCP Main process and they would be passed to TCP receiver processes when some message was received, at which point the TCP receiver would process the message and then pass the connection back to TCP main when it was done. If I used lsof or netstat they would should the connections belonging to TCP main and occasionally being moved to a TCP receiver and back as messages arrived.
>
> In the latest git version I see the connections under both TCP main and the TCP receivers all the time (even when there are no messages to process) if I look with lsof. If I look with netstat, then the connections are all listen under various TCP receiver processes and none under TCP main.
>
> Even more weird, the file descriptor for the same connection is different under TCP receiver and TCP main in lsof.
>
> Here are my processes:
>
> {
> "ID": 10,
> "PID": 21441,
> "Type": "TCP receiver"
> },
> {
> "ID": 11,
> "PID": 21442,
> "Type": "TCP receiver"
> },
> {
> "ID": 16,
> "PID": 21450,
> "Type": "TCP main"
> }
>
> And these are the TCP connections (the output never changes, the connections do not seem to be moved between TCP main and a TCP receiver and back anymore):
>
> $ sudo netstat -pan | grep opensips | grep tcp
> tcp 0 0 81.23.228.160:5060 0.0.0.0:* LISTEN 21430/./opensips
> tcp 0 0 81.23.228.160:5061 0.0.0.0:* LISTEN 21430/./opensips
> tcp 0 0 81.23.228.160:5060 86.121.160.133:44102 ESTABLISHED 21441/./opensips
> tcp 0 0 81.23.228.160:5060 152.156.209.166:56317 ESTABLISHED 21442/./opensips
>
> (notice how all established connections belong only to TCP receiver processes according to netstat)
>
> $ sudo lsof -np 21450 | grep TCP # This is TCP main
> opensips 21450 opensips 116u IPv4 580308849 0t0 TCP 81.23.228.160:sip->86.121.160.133:44102 (ESTABLISHED)
> opensips 21450 opensips 117u IPv4 580313129 0t0 TCP 81.23.228.160:sip->152.156.209.166:56317 (ESTABLISHED)
> opensips 21450 opensips 159u IPv4 580280113 0t0 TCP 81.23.228.160:sip (LISTEN)
> opensips 21450 opensips 160u IPv4 580280114 0t0 TCP 81.23.228.160:sip-tls (LISTEN)
>
> $ sudo lsof -np 21441 | grep TCP # This is the first TCP receiver
> opensips 21441 opensips 5u IPv4 580308849 0t0 TCP 81.23.228.160:sip->86.121.160.133:44102 (ESTABLISHED)
> opensips 21441 opensips 159u IPv4 580280113 0t0 TCP 81.23.228.160:sip (LISTEN)
> opensips 21441 opensips 160u IPv4 580280114 0t0 TCP 81.23.228.160:sip-tls (LISTEN)
>
> $ sudo lsof -np 21442 | grep TCP # This is the 2nd TCP receiver
> opensips 21442 opensips 5u IPv4 580313129 0t0 TCP 81.23.228.160:sip->152.156.209.166:56317 (ESTABLISHED)
> opensips 21442 opensips 159u IPv4 580280113 0t0 TCP 81.23.228.160:sip (LISTEN)
> opensips 21442 opensips 160u IPv4 580280114 0t0 TCP 81.23.228.160:sip-tls (LISTEN)
>
> As mentioned before, the output is stable and it doesn't change until the connection is closed. The connections do not seem to be moved back to TCP main. Also notice the file descriptor being 5 in the TCP receiver process and something like 116/117 in TCP main.
>
> Otherwise TCP connections seem to work, but I noticed the behavior changed from what it used to be in previous versions. Is this an issue, or is it intended?
>
> --
> Dan
>
>
>
>
>
> _______________________________________________
> Devel mailing list
> Devel at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/devel
>
--
Răzvan Crainea
OpenSIPS Core Developer
http://www.opensips-solutions.com
Meet the OpenSIPS team at the next OpenSIPS Summit:
https://www.opensips.org/events
More information about the Devel
mailing list