Bug #1178


mod_proxy_core + tomcat = hanging requests

Added by moe over 15 years ago. Updated about 6 years ago.

Target version:


i have observed the following with both lighttpd 1854 (current trunk) and 1811.

i'm using mod_proxy_core to connect to a single instance of tomcat 6.0.10 using
the following config:

$HTTP["url"] !~ "^/img/" {
    proxy-core.max-pool-size = 20
    proxy-core.protocol      = "http" 
    proxy-core.balancer      = "sqf" 
    proxy-core.backends      = ( "" )

this seems to work at first glance but about 1 out of 4 responses gets a literal '0' appended
(visible in the browser at the end of page) and the connection hangs - apparently until some timeout is hit.

i played with various settings such as proxy-core.max-pool-size = 1, http11 = disable and also
disabled keep-alive in tomcat entirely (maxKeepAliveRequests = 1). none of my tweaks could make the problem go away, some made it even worse.

i'll have to go back to 1.4.x and mod_proxy for now but would be glad if someone
could look into this...

Actions #1

Updated by Anonymous over 15 years ago

I would suggest to use AJP13 protocol with Tomcat instead of proxying HTTP requests.

At least we've successfully run almost half a year Tomcat with AJP13 with lighty 1.5-x trunk.

-- jtiai

Actions #2

Updated by Anonymous almost 15 years ago

We have exactly same problem.

BTW AJP13 seems to work much slower then HTTP proxy.

Actions #3

Updated by stepancheg almost 15 years ago

Problem was seen in the last announced version -- r1992.

Actions #4

Updated by moe almost 15 years ago

Well, we're not using tomcat anymore (left the java-world, it's all fastcgi now) but I
wonder if this is a bug in the mod_proxy_core http backend or if it's a particular problem
with tomcat.

Is anyone using the http backend for anything other than tomcat (or a servlet engine)?
Do you see the same problem?

It smells like a classic off-by-one bug to me.

Actions #5

Updated by stepancheg almost 15 years ago

Oops, trac didn't save my comment. Typing again.

mod_proxy_backend_http does not interpret 304 response properly: it always tries to read http message body. 304 requires response has no message body. So Tomcat does not send either "content-length" or "transfer-encoding: chunked" headers. So mod_proxy_backend_http reads until EOF, i. e. hangs.

I tried to

Actions #6

Updated by stepancheg almost 15 years ago

diff again:

--- mod_proxy_backend_http.c.orig    2007-11-12 22:42:14.000000000 +0300
+++ mod_proxy_backend_http.c    2007-11-12 22:23:50.000000000 +0300
@@ -226,38 +226,42 @@
 PROXY_STREAM_DECODER_FUNC(proxy_http_stream_decoder) {
     proxy_connection *proxy_con = sess->proxy_con;
     chunkqueue *in = proxy_con->recv;
     chunk *c;

     if (in->first == NULL) {
         if ((sess->content_length >= 0 && sess->bytes_read == sess->content_length) || in->is_closed) {
             sess->is_request_finished = 1;
             return HANDLER_FINISHED;

         return HANDLER_GO_ON;

     /* parse response headers. */
     if (!sess->have_response_headers) {
         handler_t rc = proxy_http_parse_response_headers(sess, in);
         if (rc != HANDLER_FINISHED) return rc;
+    if (sess->resp->status == 304) {
+        return HANDLER_FINISHED;
+    }

     if (sess->is_chunked) {
         return proxy_http_parse_chunked_stream(srv, sess, in, out);
     } else {
Actions #7

Updated by stepancheg over 14 years ago

Is anybody alive there? mod_proxy_backend_http is still broken.

Actions #8

Updated by Anonymous over 14 years ago

I have the same problem with apache and fixed it by setting KeepAlive=off in the Apache configuration (for now).

-- sui

Actions #9

Updated by stbuehler about 14 years ago

  • Status changed from New to Fixed
  • Resolution set to fixed

Fixed in r2235

Actions #10

Updated by stepancheg over 12 years ago

  • Status changed from Fixed to Reopened

Same problem with 204 response code. Patch is trivial:

diff -r 02c80992f79d src/mod_proxy_backend_http.c
--- a/src/mod_proxy_backend_http.c      Tue Mar 16 14:59:45 2010 +0300
+++ b/src/mod_proxy_backend_http.c      Fri Apr 30 23:13:50 2010 +0400
@@ -108,6 +108,7 @@

        switch (sess->resp->status) {
        case 205: /* class: header only */
+       case 204:
        case 304:
                sess->is_request_finished = 1;
Actions #11

Updated by gstrauss over 6 years ago

  • Description updated (diff)
  • Missing in 1.5.x set to Yes
Actions #12

Updated by gstrauss about 6 years ago

  • Status changed from Reopened to Obsolete

Also available in: Atom