Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Apache Tomcat »

mod_jk problem when streaming files larger than ~400k (causes
ClientAbortException)

Haroon Rafique

2006-12-04


Hi,

I am using mod_jk 1.2.19 on Linux with JDK 1.5.0_08, tomcat 5.5.20. Our
application is struts-based and in one of our actions we stream a PDF to
the client. The pseudo-code for outputting the response back to the client
is as follows (assuming baos contains a ByteArrayOutputStream):

        OutputStream out = response.getOutputStream();
        baos.writeTo(out);
        out.flush();
        out.close();

We noticed no problems when the size of baos was less than 400k. Now the
filesize has jumped to a little greater than 400k. With mod_jk in the
picture, intermittently (not all the time), we get ClientAbortException:

  Caused by: ClientAbortException: java.io.IOException
     at org.apache.catalina.connector.OutputBuffer.realWriteBytes (OutputBuffer.java:366)

The end result being that the PDF is truncated and Acrobat considers it
damaged.

Without mod_jk in the picture, everything is fine.

Turning up the mod_jk logging to debug gave me too much info. Turning it
down to info gave me some clues. Basically, there are 3 flavors of the
failures. Maybe they are all the same but it might appear different to a
trained eye, so I'm posting all three.

Flavor 1 error:
===============
[Mon Dec 04 14:28:59 2006] [25445:9920] [info]
  ajp_connection_tcp_get_message::
  jk_ajp_common.c (941): (local) Tomcat has forced a connection close for
  socket 22
[Mon Dec 04 14:28:59 2006] [25445:9920] [error]
  ajp_get_reply::jk_ajp_common.c (1562): (local) Tomcat is down or network
  problems. Part of the response has already been sent to the client
[Mon Dec 04 14:28:59 2006] [25445:9920] [info]
  ajp_service::jk_ajp_common.c (18 28): (local) receiving from tomcat failed,
  recoverable operation attempt=0
[Mon Dec 04 14:28:59 2006] [25445:9920] [info]
  ajp_service::jk_ajp_common.c (1867): (local) sending request to tomcat failed,
  recoverable operation attempt=1
[Mon Dec 04 14:28:59 2006] [25445:9920] [info]
  ajp_process_callback::jk_ajp_common.c (1410): Writing to client aborted or client
  network problems
[Mon Dec 04 14:28:59 2006] [25445:9920] [info]
  ajp_service::jk_ajp_common.c (1795): (local) request failed, because of client
  write error without recovery in send loop attempt=1
[Mon Dec 04 14:28:59 2006] [25445:9920] [info]
  jk_handler::mod_jk.c (2056): Aborting connection for worker=local

Flavor 2 error:
===============
[Mon Dec 04 14:30:30 2006] [25448:9920] [info]
  ajp_send_request::jk_ajp_common.c (1170): (local) socket 22 is not connected
  any more (errno=0)
[Mon Dec 04 14:30:30 2006] [25448:9920] [info]
  ajp_send_request::jk_ajp_common.c (1194): (local) error sending request. Will
  try another pooled connection
[Mon Dec 04 14:30:30 2006] [25448:9920] [info]
  ajp_send_request::jk_ajp_common.c (1218): (local) all endpoints are disconnected
  or dead
[Mon Dec 04 14:30:30 2006] [25448:9920] [info]
  ajp_service::jk_ajp_common.c (1867): (local) sending request to tomcat failed,
  recoverable operation attempt=1
[Mon Dec 04 14:30:32 2006] [25448:9920] [info]
  ajp_connection_tcp_get_message::jk_ajp_common.c (941): (local) Tomcat has
  forced a connection close for socket 22
[Mon Dec 04 14:30:32 2006] [25448:9920] [error]
  ajp_get_reply::jk_ajp_common.c (1562): (local) Tomcat is down or network
  problems. Part of the response has already been sent to the client
[Mon Dec 04 14:30:32 2006] [25448:9920] [info]
  ajp_service::jk_ajp_common.c (1828): (local) receiving from tomcat failed,
  recoverable operation attempt=1
[Mon Dec 04 14:30:32 2006] [25448:9920] [info]
  ajp_service::jk_ajp_common.c (1867): (local) sending request to tomcat failed,
  recoverable operation attempt=2
[Mon Dec 04 14:30:32 2006] [25448:9920] [error]
  ajp_service::jk_ajp_common.c (1879): (local) Connecting to tomcat failed.
  Tomcat is probably not started or is listening on the wrong port
[Mon Dec 04 14:30:32 2006] [25448:9920] [info]
  jk_handler::mod_jk.c (2063): Service error=0 for worker=local

Flavor 3 error:
===============
[Mon Dec 04 14:32:31 2006] [25444:9920] [info]
  ajp_send_request::jk_ajp_common.c (1170): (local) socket 22 is not
  connected any more (errno=0)
[Mon Dec 04 14:32:31 2006] [25444:9920] [info]
  ajp_send_request::jk_ajp_common.c (1194): (local) error sending
  request. Will try another pooled connection
[Mon Dec 04 14:32:31 2006] [25444:9920] [info]
  ajp_send_request::jk_ajp_common.c (1218): (local) all endpoints are
  disconnected or dead
[Mon Dec 04 14:32:31 2006] [25444:9920] [info]
  ajp_service::jk_ajp_common.c (1867): (local) sending request to tomcat
  failed, recoverable operation attempt=1


Does anyone have any experience with streaming large files using mod_jk?
If I don't get any responses I will try the dev list.

Here's my mod_jk.conf:

LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
JkShmFile logs/mod_jk.shm
JkMount /jkstatus/ status
JkMount /sws/* local

Here's my workers.properties:

worker.list=local,status
worker.local.type=ajp13
worker.local.port=8009
worker.local.host=localhost
worker.status.type=status
worker.status.port=8009
worker.status.host=localhost

Anyone see any glaring mistakes or oddities? As I mentioned earlier, the
same setup worked fine. The only trigger that I can think of is the slight
increase in file size.

Any help appreciated.

thanks,
--
Haroon Rafique
<haroon.rafique@(protected)>


---------------------------------------------------------------------
To start a new topic, e-mail: users@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.