[OpenSIPS-Devel] TCP connection behavior

Dan Pascu dan at ag-projects.com
Tue May 21 07:55:39 EDT 2019


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







More information about the Devel mailing list