Project

General

Profile

[UE] TCP-FIN is not propagated to the backend scgi server when Browser closes the session (TCP-FIN sent)

Added by joo almost 4 years ago

Hi,
1) Firefox browser(76.0.1 64-bit)
2) lighthttpd 1.4.45

lighttpd.conf:

server.modules = (
    "mod_access",
    "mod_alias",
    "mod_cgi",
    "mod_scgi",
    "mod_compress",
    "mod_redirect",
)

server.document-root        = "/var/www/html" 
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log" 
server.pid-file             = "/var/run/lighttpd.pid" 
server.username             = "www-data" 
server.groupname            = "www-data" 
server.port                 = 80
server.stream-response-body = 2
server.stream-request-body  = 2

index-file.names            = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny             = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

compress.cache-dir          = "/var/cache/lighttpd/compress/" 
compress.filetype           = ( "application/javascript", "text/css", "text/html", "text/plain" )

# default listening port for IPv6 falls back to the IPv4 port
## Use ipv6 if available
#include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl" 
include_shell "/usr/share/lighttpd/include-conf-enabled.pl" 

$HTTP["url"] =~ "^/cgi-bin/" {
        alias.url += ( "/cgi-bin/" => "/var/www/cgi-bin/" )
        cgi.assign = ( ".cgi"  => "", 
                       ".py"  => "/usr/bin/python",
                       ".php"  => "/usr/bin/php" )
}

cgi.assign      = (
       ".cgi"  => "",
       ".py"  => "/usr/bin/python",
       ".php"  => "/usr/bin/php" 

)

scgi.server = ( ".scgi" =>
    ( "scgi-tcp" =>
      (
        "host" => "127.0.0.1",
        "port" => 9998,
        "check-local" => "disable",
        "tcp-fin-propagate" => "enable" 
      )
    )
)

I use and modify the the test code (scgi-responder.c) that comes with the package. I added a line at near the end of the scgi_process function:
        if (0 == strcmp(p, "path_info")) {
            printf("%s", scgi_getenv(r, rlen, "PATH_INFO"));
        } else if (0 == strcmp(p, "script_name")) {
            printf("%s", scgi_getenv(r, rlen, "SCRIPT_NAME"));
        } else if (0 == strcmp(p, "var")) {
            p = scgi_getenv(r, rlen, "X_LIGHTTPD_FCGI_AUTH");
            printf("%s", p ? p : "(no value)");
        } else {
            rd = recv(fd, buf, 100, 0);          ==========> Add this
            if ( rd <= 0)
            {
                printf("test123");
            }
        }
    }

    fflush(stdout);
    if (0 == num_requests) finished = 1;
} 

From the Browser, I load a html page and open a scgi session:
function loadField(url, id)
 { 
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById(id).value =
      this.responseText;
    }
  };
  xhttp.open("GET", url, true);
  xhttp.send();
 }

loadField('cgi-bin/scgi-bin.scgi?region=0', 'myHeader1');

</script>

</body>
</html>

I set a break point at the recv point (===> Add this), and when the above javascript executes, the program does hit the break point. When I close the Browser tab and TCP-FIN is sent, the recv call does not return as expected. I am wondering if this feature works in 1.4.45 version?

Thanks,

Joo


Replies (4)

RE: [UE] TCP-FIN is not propagated to the backend scgi server when Browser closes the session (TCP-FIN sent) - Added by gstrauss almost 4 years ago

Marked User Error. lighttpd 1.4.45 is over 3 years old. There have been 10 major releases since. lighttpd 1.4.55 was released in Jan 2020.

I am wondering if this feature works in 1.4.45 version?

RTFM. lighttpd wiki documents that "tcp-fin-propagate" was added in lighttpd 1.4.50.

test/scgi-responder.c, the reference code that you used above, was added to lighttpd in 1.4.46.

2) lighthttpd 1.4.45

lighttpd.conf:

"lighttpd" is spelled "lighttpd"

RE: [UE] TCP-FIN is not propagated to the backend scgi server when Browser closes the session (TCP-FIN sent) - Added by joo almost 4 years ago

I ran more testing using SCGI on Server Sent Event functionality with 1.4.54. It seems like if there is no data sent back by the backend, this TCP-FIN propagation feature does not work all the time. Sometimes it works at the first try, and it usually fails at the second and third try.

Thanks

Joo

RE: [UE] TCP-FIN is not propagated to the backend scgi server when Browser closes the session (TCP-FIN sent) - Added by joo almost 4 years ago

Could you please point me where is the code I should look at?

Thanks

    (1-4/4)