java - tomcat timing out if no activity in 20s? -


if setup tomcat , stream static file it, i've noticed if client "pauses" (stops receiving) socket > 20s tomcat appears "sever" connection arbitrarily (even though require uri line has been received , connection still "connected" [client still alive]). configuration parameter controls this? documentation mentions connectiontimeout in connection initial header parsing , reading request body, not reading server's response [?] there kind of inactivity timeout going on here?

it reproducible, stream (large) static file tomcat app, , receive client pauses, ex test.rb:

require "socket" host = "localhost" port = 8080 socket = tcpsocket.new host,port url = "/your_webapp/large_static_filename.ext" request = "get #{url} http/1.0\r\nhost:#{host}\r\n\r\n" socket.print request puts "reading" response = socket.sysread 1_000_000 puts response.length puts response[0..300] puts "sleeping 25" # 10s or several reads separated 10s, ok sleep 25 response2 = socket.read # should equal total size, doesn't... puts "sum=#{response2.length + response.length}" 

it works fine other servers, not kind of os limit @ play. it's vanilla tomcat no mod_jk or workers @ play...

the thing affected "inactivity timeout" appears

<connector port="8080" ... connectiontimeout=30000 /> setting.

and if it's trying actively 'send data' onto wire (but can't because client actively refusing or if connection has been lost). if servlet busy doing cpu in background, writes wire (and it's received or buffered kernel), no problem, can exceed connectiontimeout, it's not this.

my hunch tomcat seems have "built in" (undocumented? not able specified separately?) write timeout setting, defaults connectiontimeout value, ex (from tomcat source, randomly selected):

java/org/apache/tomcat/util/net/nioendpoint.java 625:            ka.setwritetimeout(getconnectiontimeout()); 

now whether "bad" or not subject interpretation. running "severing" of connection tomcat occurs after either tcp channel has been disrupted somehow (enough stop transfer) or client "blocking" on receiving bytes, fwiw...

fwiw connectiontimeout setting affects many things:

the total amount of time takes receive http request. total amount of time between receipt of tcp packets on post or put request. total amount of time between acks on transmissions of tcp packets in responses. 

and apparently writetimeout.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -