tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rainer Jung <rainer.j...@kippdata.de>
Subject Re: Problem with mod_jk / tomcat on file streaming
Date Fri, 01 Jun 2007 08:04:12 GMT
Have a look at the flush options on

http://tomcat.apache.org/connectors-doc/reference/apache.html

and maybe at the various timeouts at

http://tomcat.apache.org/connectors-doc/reference/workers.html

There is also a Timeout directive for Apache httpd.

If you can't find it out, post your config and more details: in case you 
can reproduce, you can set JkLogLevel to trace and we'll most likely 
see, why mod_jk closes the connection to Tomcat (if so). Packet dumps 
are also helpful.

There is no known issue, apart from the need of correct flush settings 
for streaming.

Regards,

Rainer

MAHAINDRA Ketut wrote:
> Hello all,
> 
>  
> 
> I have a problem when using Tomcat 5.5.23 and apache/mod_jk 1.2.23.
> 
> I have a piece of code that will stream a file when a download request
> is made by a user.
> 
>  
> 
> ...
> 
> response.setContentType("application/octet-stream");
> 
> response.setContentLength((int)fDownload.length());
> 
> response.setHeader("Content-Disposition", "attachment; filename=\"" +
> fromFileName + "\"");
> 
>  
> 
> // read the fromFile and write to output stream
> 
> FileInputStream  fis = new FileInputStream(location + "/" +
> fromFileName);   //$NON-NLS-1$
> 
> BufferedOutputStream bos = new
> BufferedOutputStream(response.getOutputStream());  
> 
> int iLen =0;
> 
> byte[]  buffer  =  new  byte[4096];             
> 
> while  ((iLen = fis.read(buffer))  !=  -1)  {  
> 
>     bos.write(buffer,0,iLen);
> 
> }
> 
> fis.close();  
> 
> bos.close();
> 
> ...
> 
>  
> 
> When the application is accessed directly through Tomcat on port 8080,
> there is no problem.
> 
> But when we put apache / mod_jk to provide connection to tomcat, the
> stream is disconnected prematurely at around 450K with the following
> exceptions logged in catalina.out.
> 
>  
> 
> ClientAbortException:  java.io.IOException
> 
>         at
> org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.j
> ava:366)
> 
>         at
> org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:432)
> 
>         at
> org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:347)
> 
>         at
> org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:
> 392)
> 
>         at
> org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:381)
> 
>         at
> org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStrea
> m.java:89)
> 
>         at
> java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
> 
>         at
> java.io.BufferedOutputStream.write(BufferedOutputStream.java:109)
> 
>         at
> com.gemalto.tools.lkms.actions.ManageVersionAction.downloadFile(Unknown
> Source)
> 
>         at
> com.gemalto.tools.lkms.actions.ManageVersionAction.execute(Unknown
> Source)
> 
>         at
> org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAc
> tion.java:58)
> 
>         at
> org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractE
> xecuteAction.java:67)
> 
>         at
> org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommand
> Base.java:51)
> 
>         at
> org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
> 
>         at
> org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.jav
> a:304)
> 
>         at
> org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
> 
>         at
> org.apache.struts.chain.ComposableRequestProcessor.process(ComposableReq
> uestProcessor.java:283)
> 
>         at
> org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
> 
>         at
> org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
> 
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
> 
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> 
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
> tionFilterChain.java:269)
> 
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
> erChain.java:188)
> 
>         at
> com.gemalto.tools.lkms.util.SetCharacterEncodingFilter.doFilter(Unknown
> Source)
> 
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
> tionFilterChain.java:215)
> 
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
> erChain.java:188)
> 
>         at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
> e.java:210)
> 
>         at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv
> e.java:174)
> 
>         at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
> :127)
> 
>         at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
> :117)
> 
>         at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:542
> )
> 
>         at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
> java:108)
> 
>         at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:1
> 51)
> 
>         at
> org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:444)
> 
>         at
> org.apache.coyote.ajp.AjpAprProtocol$AjpConnectionHandler.process(AjpApr
> Protocol.java:472)
> 
>         at
> org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1286)
> 
>         at java.lang.Thread.run(Thread.java:595)
> 
> Caused by: java.io.IOException
> 
>         at
> org.apache.coyote.ajp.AjpAprProcessor.flush(AjpAprProcessor.java:1197)
> 
>         at
> org.apache.coyote.ajp.AjpAprProcessor$SocketOutputBuffer.doWrite(AjpAprP
> rocessor.java:1282)
> 
>         at org.apache.coyote.Response.doWrite(Response.java:560)
> 
>         at
> org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.j
> ava:361)
> 
>         ... 36 more
> 
>  
> 
>  
> 
> Is there any issue on the code ?
> 
> Or is it a known mod_jk issue ? Or is it perhaps a configuration issue
> on my side ?

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message