为Tomcat NioChannel设置writeTimeout

时间:2017-03-23 19:14:13

标签: java multithreading tomcat

如何为Tomcat响应设置writeTimeout?更具体地说,我的意思是NioChannel的writeTimeout中的KeyAttachment - 字段,在将块写入Socket并且默认为无限时使用,这不适合我的用例。我只能找到有关如何设置读取超时或connectionTimeout的信息。

使用KeyAttachment中的writeTimeout的代码可在此处找到:http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tomcat.embed/tomcat-embed-core/8.0.24/org/apache/coyote/http11/InternalNioOutputBuffer.java#129

NioEndpoint.KeyAttachment att = (NioEndpoint.KeyAttachment)socket.getAttachment();
if ( att == null ) throw new IOException("Key must be cancelled");
long writeTimeout = att.getWriteTimeout();

这个问题的动机来自这个问题:Spring StreamingResponseBody Request Thread not cleaned up, when client closes connection

0 个答案:

没有答案