Bug 66463 - Socket Stuck on: proxy_fcgi:error (104)Connection reset by peer:
Summary: Socket Stuck on: proxy_fcgi:error (104)Connection reset by peer:
Status: NEW
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: All (show other bugs)
Version: 2.5-HEAD
Hardware: All All
: P1 normal with 1 vote (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-02 16:48 UTC by lg@efficientip.com
Modified: 2024-04-28 00:12 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description lg@efficientip.com 2023-02-02 16:48:25 UTC
Hello

Since the upgrade to httpd 2.4.55 when I restart the my backend ( php-fpm )
The connection stays open instead of being closed.


To test it I use this Configuration : 

---- httpd.conf ----

Listen 443

LoadModule mpm_event_module modules/mod_mpm_event.so

LoadModule http2_module modules/mod_http2.so
Protocols h2 h2c http/1.1

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModule ssl_module modules/mod_ssl.so

DirectoryIndex index.php index.html
<FilesMatch \.php$>
#    SetHandler "proxy:unix:/run/php-fpm/php-fpm.sock|fcgi://localhost/"
    SetHandler "proxy:unix:/run/php-fpm-legacy/php-fpm.sock|fcgi://localhost/"
</FilesMatch>
<Proxy "fcgi://localhost" enablereuse=off flushpackets=on timeout=300>
</Proxy>

<VirtualHost *:443>
   DocumentRoot /srv/http
   SSLEngine on
   SSLHonorCipherOrder off
   SSLCertificateFile /data/ssl/host.crt
   SSLCertificateKeyFile /data/ssl/host.key
   SSLOpenSSLConfCmd DHParameters /data1/ssl/dhparams.pem
   SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
</VirtualHost>

----




My simple HTML code : 
----- index.html ----
<html>
  <body>
<h1>SSE demo with PHP</h1>

<ol id="list">
</ol>

<script>
  // Create new event, the server script is sse.php
  var eventSource = new EventSource("sse.php");

  // Event when receiving a message from the server
  eventSource.onmessage = function(event) {
      // Append the message to the ordered list
      document.getElementById("list").innerHTML += '<li>'+event.data + "</li>";
  };
</script>

  </body>
</html>
------------

The PHP code : 
------ sse.php -----
<?php

ini_set('session.use_cookies',false);
session_cache_limiter(false);
session_start();

header("Content-Type: text/event-stream");
header("Cache-Control: no-cache");
header("Access-Control-Allow-Origin: *");

function sendMsg($id, $msg) {
  echo "id: $id" . PHP_EOL;
  echo "data: $msg" . PHP_EOL;
  echo PHP_EOL;
  ob_flush();
  flush();
}

while (1) {
      $serverTime = time();
      sendMsg($serverTime, 'server time: ' . date("h:i:s", time()));
      sleep(1);
}
------------------


I Just have to go on the /index.html and restart php-fpm to have the issue.

And if I remove the module http2 by commenting these 2 lines
#LoadModule http2_module modules/mod_http2.so
#Protocols h2 h2c http/1.1

Everything is Working.

----- httpd -V ----
Server version: Apache/2.4.55 (Unix)
Server built:   Jan 18 2023 19:03:59
Server's Module Magic Number: 20120211:126
Server loaded:  APR 1.7.0, APR-UTIL 1.6.1, PCRE 10.41 2022-12-06
Compiled using: APR 1.7.0, APR-UTIL 1.6.1, PCRE 10.40 2022-04-14
Architecture:   64-bit
Server MPM:     event
  threaded:     yes (fixed thread count)
    forked:     yes (variable process count)
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_PROC_PTHREAD_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/bin/suexec"
 -D DEFAULT_PIDLOG="/run/httpd/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"
--------
Comment 1 lg@efficientip.com 2023-02-02 16:55:01 UTC
You can also see the issues using a simple curl on the sse.php

curl -k --http2 https://URL/sse.php