开发者

tomcat socketTimeout exception

I am simulating ajax file download using iframe, the request goes to tomcat app(servlet) for a file download which is a time consuming process(might take more than 1 min), the issue is that after certain amount of time, either tomcat or the browser client terminates the connection. see Tomcat exception below. who is terminating it, client or server? is there a way I can increase the timeout?

var iframe = document.createElement("iframe");

iframe.src="http://xxxxxxxxx?";
Caused by: ClientAbortException:  java.net.SocketException: Broken pipe
        at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:358)
        at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:434)
        at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:349)
        at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:381)
        at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:370)
        at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:89)
        at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:83)
        at org.apache.poi.poifs.storage.BigBlock.doWriteData(BigBlock.java:55)
        at org.apache.poi.poifs.storage.DocumentBlock.writeData(DocumentBlock.java:220)
        at org.apache.poi.poifs.storage.BigBlock.writeBlocks(BigBlock.java:86)
        at org.apache.poi.poifs.filesystem.POIFSDocument$BigBlockStore.writeBlocks(POIFSDocument.java:603)
        at org.apache.poi.poifs.filesystem.POIFSDocument.writeBlocks(POIFSDocument.java:275)
        at org.apache.poi.poifs.filesystem.POIFSFileSystem.writeFilesystem(POIFSFileSystem.java:390)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:1168)
        at net.sf.jasperreports.engine.export.JRXlsExporter.closeWorkbook(JRXlsExporter.java:199)
        ... 17 more
Caused by: java.net.SocketException: Broken pipe
        at java.net.SocketOutputStream.socketWrite0(Na开发者_如何学Ctive Method)
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)


The exception you are seeing is caused by the client timing out and closing the connection.

For long running requests, a typical pattern is for the initial request to hit the server to fire off some long running piece of work. You could for example put a message on an MDB to create a pdf. The servlet then sends a 202 Accepted response to the client, with a new URL designed to be polled. The client then needs to continue to poll this new URL until the resource is available. This requires a bit of JavaScript, and some sites will have a progress bar while the client polls to see if the resource is available.

If you don't provide feedback to the client, they generally will hit the stop button and refresh the page after a bit of time. This can make matters worse if you attempt a large operation on each of these requests.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜