You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by GOMEZ Henri <hg...@slib.fr> on 2001/10/08 15:14:47 UTC

ajp13 and tomcat 4.0 - Must set connectionTimeout to 0

Hi to all,

It seems that Ajp13Connector use a timeout set in Tomcat 4.0, 
notimeout in TC 3.2/3.3 and since ajp13 connection ARE persistant 
we have Read timed out error :

Here is the kind of problems you'll see (thanks Xavier)
A solution will be set connectionTimeout to 0 in server.xml :



    <Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
               port="8009" minProcessors="5" maxProcessors="75"
               acceptCount="10" debug="0" connectionTimeout="0" />



001-10-08 09:57:04 Ajp13Connector[8009] Opening server socket on all host IP
addresses
2001-10-08 09:57:04 Ajp13Connector[8009] Starting background thread
2001-10-08 09:57:04 Ajp13Processor[8009][0] Starting background thread
2001-10-08 09:57:04 Ajp13Processor[8009][1] Starting background thread
2001-10-08 09:57:04 Ajp13Processor[8009][2] Starting background thread
2001-10-08 09:57:04 Ajp13Processor[8009][3] Starting background thread
2001-10-08 09:57:04 Ajp13Processor[8009][4] Starting background thread
2001-10-08 09:58:45 Ajp13Processor[8009][4] process:
ajp13.receiveNextRequest
java.io.InterruptedIOException: Read timed out
	at java.net.SocketInputStream.socketRead(Native Method)
	at java.net.SocketInputStream.read(SocketInputStream.java:86)
	at org.apache.ajp.Ajp13.readN(Ajp13.java:849)
	at org.apache.ajp.Ajp13.receive(Ajp13.java:889)
	at org.apache.ajp.Ajp13.receiveNextRequest(Ajp13.java:285)
	at
org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:339)
	at
org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:424)
	at java.lang.Thread.run(Thread.java:484)

Re: ajp13 and tomcat 4.0 - Must set connectionTimeout to 0

Posted by jean-frederic clere <jf...@fujitsu-siemens.com>.
Hi,

Another possible way would be to apply the following patch:
+++
Index: java/org/apache/ajp/Ajp13.java
===================================================================
RCS file:
/home/cvs/mirror/jakarta-tomcat-connectors/jk/java/org/apache/ajp/Ajp13.java,v
retrieving revision 1.16
diff -u -r1.16 Ajp13.java
--- java/org/apache/ajp/Ajp13.java      2001/10/01 20:50:39     1.16
+++ java/org/apache/ajp/Ajp13.java      2001/10/08 12:56:38
@@ -214,6 +214,8 @@
 
     OutputStream out;
     InputStream in;
+    Socket socket;
+    int connectionTimeout;
 
     // Buffer used of output body and headers
     Ajp13Packet outBuf = new Ajp13Packet( MAX_PACKET_SIZE );
@@ -265,6 +267,8 @@
        socket.setSoLinger( true, 100);
        out = socket.getOutputStream();
        in  = socket.getInputStream();
+        connectionTimeout = socket.getSoTimeout();
+        this.socket = socket;
        pos = 0;
     }
 
@@ -286,6 +290,7 @@
 
        // XXX The return values are awful.
 
+        socket.setSoTimeout(0);
        int err = receive(hBuf);
        if(err < 0) {
            return 500;
@@ -864,6 +869,8 @@
             if (got < 0)
                 return JK_AJP13_COMM_BROKEN;
 
+            if (socket.getSoTimeout()!=connectionTimeout)
+                socket.setSoTimeout(connectionTimeout);
             pos += got;
         }
         return pos;
+++
That way we are sure we are not blocked when the read is hanging in the midle of
a message.

Cheers

Jean-frederic

GOMEZ Henri wrote:
> 
> Hi to all,
> 
> It seems that Ajp13Connector use a timeout set in Tomcat 4.0,
> notimeout in TC 3.2/3.3 and since ajp13 connection ARE persistant
> we have Read timed out error :
> 
> Here is the kind of problems you'll see (thanks Xavier)
> A solution will be set connectionTimeout to 0 in server.xml :
> 
>     <Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
>                port="8009" minProcessors="5" maxProcessors="75"
>                acceptCount="10" debug="0" connectionTimeout="0" />
> 
> 001-10-08 09:57:04 Ajp13Connector[8009] Opening server socket on all host IP
> addresses
> 2001-10-08 09:57:04 Ajp13Connector[8009] Starting background thread
> 2001-10-08 09:57:04 Ajp13Processor[8009][0] Starting background thread
> 2001-10-08 09:57:04 Ajp13Processor[8009][1] Starting background thread
> 2001-10-08 09:57:04 Ajp13Processor[8009][2] Starting background thread
> 2001-10-08 09:57:04 Ajp13Processor[8009][3] Starting background thread
> 2001-10-08 09:57:04 Ajp13Processor[8009][4] Starting background thread
> 2001-10-08 09:58:45 Ajp13Processor[8009][4] process:
> ajp13.receiveNextRequest
> java.io.InterruptedIOException: Read timed out
>         at java.net.SocketInputStream.socketRead(Native Method)
>         at java.net.SocketInputStream.read(SocketInputStream.java:86)
>         at org.apache.ajp.Ajp13.readN(Ajp13.java:849)
>         at org.apache.ajp.Ajp13.receive(Ajp13.java:889)
>         at org.apache.ajp.Ajp13.receiveNextRequest(Ajp13.java:285)
>         at
> org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:339)
>         at
> org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:424)
>         at java.lang.Thread.run(Thread.java:484)

Re: ajp13 and tomcat 4.0 - Must set connectionTimeout to 0

Posted by Remy Maucherat <rm...@home.com>.
> Hi to all,
>
> It seems that Ajp13Connector use a timeout set in Tomcat 4.0,
> notimeout in TC 3.2/3.3 and since ajp13 connection ARE persistant
> we have Read timed out error :
>
> Here is the kind of problems you'll see (thanks Xavier)
> A solution will be set connectionTimeout to 0 in server.xml :
>
>
>
>     <Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
>                port="8009" minProcessors="5" maxProcessors="75"
>                acceptCount="10" debug="0" connectionTimeout="0" />

Moving to the dev list ...

A negative value would work (connectionTimeout = -1), but I think the
setSoTimeout code should just be removed in the AJP connector (you can go
ahead and do it if you get the chance, otherwise, I'll do it later today).

The Tomcat 3.3 AJP 1.4 interceptor doesn't call Socket.setKeepAlive(true)
either (I don't see a problem with that one, though).

Remy