<div id="content_views" class="markdown_views"> <!-- flowchart 箭頭圖標 勿刪 --> <svg xmlns="http://www.w3.org/2000/svg" style="display: none;"> <path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></path> </svg> <p>這兩天忽然看到日誌文件中有「java.io.IOException: 您的主機中的軟件停止了一個已創建的鏈接。」錯誤,因此特意查了下緣由。</p>css
<pre class="prettyprint" name="code"><code class="hljs avrasm has-numbering css" onclick="mdcp.signin(event)" style="position: unset;"><span class="hljs-label"><span class="hljs-selector-tag">org</span><span class="hljs-selector-class">.apache</span><span class="hljs-selector-class">.catalina</span><span class="hljs-selector-class">.connector</span><span class="hljs-selector-class">.ClientAbortException</span>:</span> <span class="hljs-selector-tag">java</span><span class="hljs-preprocessor"><span class="hljs-selector-class">.io</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.IOException</span></span>: 您的主機中的軟件停止了一個已創建的鏈接。 <span class="hljs-selector-tag">at</span> <span class="hljs-selector-tag">org</span><span class="hljs-preprocessor"><span class="hljs-selector-class">.apache</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.catalina</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.connector</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.OutputBuffer</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.realWriteBytes</span></span>(<span class="hljs-selector-tag">OutputBuffer</span><span class="hljs-preprocessor"><span class="hljs-selector-class">.java</span></span><span class="hljs-selector-pseudo">:</span><span class="hljs-number"><span class="hljs-selector-pseudo">396</span></span><span class="hljs-selector-pseudo">)</span> ~<span class="hljs-selector-attr">[catalina</span><span class="hljs-preprocessor"><span class="hljs-selector-attr">.jar</span></span><span class="hljs-selector-attr">:</span><span class="hljs-number"><span class="hljs-selector-attr">8.0</span></span><span class="hljs-number"><span class="hljs-selector-attr">.35</span></span><span class="hljs-selector-attr">]</span> <span class="hljs-selector-tag">at</span> <span class="hljs-selector-tag">org</span><span class="hljs-preprocessor"><span class="hljs-selector-class">.apache</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.tomcat</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.util</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.buf</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.ByteChunk</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.flushBuffer</span></span>(<span class="hljs-selector-tag">ByteChunk</span><span class="hljs-preprocessor"><span class="hljs-selector-class">.java</span></span><span class="hljs-selector-pseudo">:</span><span class="hljs-number"><span class="hljs-selector-pseudo">426</span></span><span class="hljs-selector-pseudo">)</span> ~<span class="hljs-selector-attr">[tomcat-util</span><span class="hljs-preprocessor"><span class="hljs-selector-attr">.jar</span></span><span class="hljs-selector-attr">:</span><span class="hljs-number"><span class="hljs-selector-attr">8.0</span></span><span class="hljs-number"><span class="hljs-selector-attr">.35</span></span><span class="hljs-selector-attr">]</span> <span class="hljs-selector-tag">at</span> <span class="hljs-selector-tag">org</span><span class="hljs-preprocessor"><span class="hljs-selector-class">.apache</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.tomcat</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.util</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.buf</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.ByteChunk</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.append</span></span>(<span class="hljs-selector-tag">ByteChunk</span><span class="hljs-preprocessor"><span class="hljs-selector-class">.java</span></span><span class="hljs-selector-pseudo">:</span><span class="hljs-number"><span class="hljs-selector-pseudo">339</span></span><span class="hljs-selector-pseudo">)</span> ~<span class="hljs-selector-attr">[tomcat-util</span><span class="hljs-preprocessor"><span class="hljs-selector-attr">.jar</span></span><span class="hljs-selector-attr">:</span><span class="hljs-number"><span class="hljs-selector-attr">8.0</span></span><span class="hljs-number"><span class="hljs-selector-attr">.35</span></span><span class="hljs-selector-attr">]</span> <span class="hljs-selector-tag">at</span> <span class="hljs-selector-tag">org</span><span class="hljs-preprocessor"><span class="hljs-selector-class">.apache</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.catalina</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.connector</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.OutputBuffer</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.writeBytes</span></span>(<span class="hljs-selector-tag">OutputBuffer</span><span class="hljs-preprocessor"><span class="hljs-selector-class">.java</span></span><span class="hljs-selector-pseudo">:</span><span class="hljs-number"><span class="hljs-selector-pseudo">421</span></span><span class="hljs-selector-pseudo">)</span> ~<span class="hljs-selector-attr">[catalina</span><span class="hljs-preprocessor"><span class="hljs-selector-attr">.jar</span></span><span class="hljs-selector-attr">:</span><span class="hljs-number"><span class="hljs-selector-attr">8.0</span></span><span class="hljs-number"><span class="hljs-selector-attr">.35</span></span><span class="hljs-selector-attr">]</span> <span class="hljs-selector-tag">at</span> <span class="hljs-selector-tag">org</span><span class="hljs-preprocessor"><span class="hljs-selector-class">.apache</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.catalina</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.connector</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.OutputBuffer</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.write</span></span>(<span class="hljs-selector-tag">OutputBuffer</span><span class="hljs-preprocessor"><span class="hljs-selector-class">.java</span></span><span class="hljs-selector-pseudo">:</span><span class="hljs-number"><span class="hljs-selector-pseudo">409</span></span><span class="hljs-selector-pseudo">)</span> ~<span class="hljs-selector-attr">[catalina</span><span class="hljs-preprocessor"><span class="hljs-selector-attr">.jar</span></span><span class="hljs-selector-attr">:</span><span class="hljs-number"><span class="hljs-selector-attr">8.0</span></span><span class="hljs-number"><span class="hljs-selector-attr">.35</span></span><span class="hljs-selector-attr">]</span> <span class="hljs-selector-tag">at</span> <span class="hljs-selector-tag">org</span><span class="hljs-preprocessor"><span class="hljs-selector-class">.apache</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.catalina</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.connector</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.CoyoteOutputStream</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.write</span></span>(<span class="hljs-selector-tag">CoyoteOutputStream</span><span class="hljs-preprocessor"><span class="hljs-selector-class">.java</span></span><span class="hljs-selector-pseudo">:</span><span class="hljs-number"><span class="hljs-selector-pseudo">97</span></span><span class="hljs-selector-pseudo">)</span> ~<span class="hljs-selector-attr">[catalina</span><span class="hljs-preprocessor"><span class="hljs-selector-attr">.jar</span></span><span class="hljs-selector-attr">:</span><span class="hljs-number"><span class="hljs-selector-attr">8.0</span></span><span class="hljs-number"><span class="hljs-selector-attr">.35</span></span><span class="hljs-selector-attr">]</span> <span class="hljs-selector-tag">at</span> <span class="hljs-keyword"><span class="hljs-selector-tag">com</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.fasterxml</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.jackson</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.core</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.json</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.UTF</span></span><span class="hljs-selector-class">8JsonGenerator</span><span class="hljs-selector-class">._flushBuffer</span>(<span class="hljs-selector-tag">UTF8JsonGenerator</span><span class="hljs-preprocessor"><span class="hljs-selector-class">.java</span></span><span class="hljs-selector-pseudo">:</span><span class="hljs-number"><span class="hljs-selector-pseudo">1819</span></span><span class="hljs-selector-pseudo">)</span> ~<span class="hljs-selector-attr">[jackson-core-</span><span class="hljs-number"><span class="hljs-selector-attr">2.1</span></span><span class="hljs-number"><span class="hljs-selector-attr">.0</span></span><span class="hljs-preprocessor"><span class="hljs-selector-attr">.jar</span></span><span class="hljs-selector-attr">:</span><span class="hljs-number"><span class="hljs-selector-attr">2.1</span></span><span class="hljs-number"><span class="hljs-selector-attr">.0</span></span><span class="hljs-selector-attr">]</span> <span class="hljs-selector-tag">at</span> <span class="hljs-keyword"><span class="hljs-selector-tag">com</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.fasterxml</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.jackson</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.core</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.json</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.UTF</span></span><span class="hljs-selector-class">8JsonGenerator</span><span class="hljs-preprocessor"><span class="hljs-selector-class">.writeString</span></span>(<span class="hljs-selector-tag">UTF8JsonGenerator</span><span class="hljs-preprocessor"><span class="hljs-selector-class">.java</span></span><span class="hljs-selector-pseudo">:</span><span class="hljs-number"><span class="hljs-selector-pseudo">436</span></span><span class="hljs-selector-pseudo">)</span> ~<span class="hljs-selector-attr">[jackson-core-</span><span class="hljs-number"><span class="hljs-selector-attr">2.1</span></span><span class="hljs-number"><span class="hljs-selector-attr">.0</span></span><span class="hljs-preprocessor"><span class="hljs-selector-attr">.jar</span></span><span class="hljs-selector-attr">:</span><span class="hljs-number"><span class="hljs-selector-attr">2.1</span></span><span class="hljs-number"><span class="hljs-selector-attr">.0</span></span><span class="hljs-selector-attr">]</span> <span class="hljs-selector-tag">at</span> <span class="hljs-keyword"><span class="hljs-selector-tag">com</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.fasterxml</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.jackson</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.databind</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.ser</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.std</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.StringSerializer</span></span><span class="hljs-preprocessor"><span class="hljs-selector-class">.serialize</span></span>(<span class="hljs-selector-tag">StringSerializer</span><span class="hljs-preprocessor"><span class="hljs-selector-class">.java</span></span><span class="hljs-selector-pseudo">:</span><span class="hljs-number"><span class="hljs-selector-pseudo">38</span></span><span class="hljs-selector-pseudo">)</span> ~<span class="hljs-selector-attr">[jackson-databind-</span><span class="hljs-number"><span class="hljs-selector-attr">2.1</span></span><span class="hljs-number"><span class="hljs-selector-attr">.0</span></span><span class="hljs-preprocessor"><span class="hljs-selector-attr">.jar</span></span><span class="hljs-selector-attr">:</span><span class="hljs-number"><span class="hljs-selector-attr">2.1</span></span><span class="hljs-number"><span class="hljs-selector-attr">.0</span></span><span class="hljs-selector-attr">]</span> <span class="hljs-selector-tag">at</span> <div class="hljs-button signin" data-title="登陸後複製"></div></code></pre>java
<p>在tomcat中出現這個錯誤是因爲客戶端在發送請求後,還沒等服務器響應就斷開了鏈接,有多是由於網絡緣由,忽然網斷了,可是若是錯誤頻繁出現的話,可能就是服務端的問題了。</p>web
<p>tomcat中配置了一個鏈接超時時間connectionTimeout,若是在這個時間以後客戶端還未獲得服務器端的響應的話,就會主動斷開鏈接,這樣就會出現上述異常了,tomcat中默認的鏈接超時時間是20秒,咱們通常最好設置爲60秒,從而避免後臺程序處理時間長致使鏈接斷開。</p>apache
<p><strong>設置方法</strong> <br> 進入tomcat中conf目錄,打開server.xml文件,找到配置端口的地方</p>json
<pre class="prettyprint" name="code"><code class="hljs xml has-numbering" onclick="mdcp.signin(event)" style="position: unset;"><span class="hljs-tag"><span class="hljs-tag"><</span><span class="hljs-title"><span class="hljs-tag"><span class="hljs-name">Connector</span></span></span><span class="hljs-tag"> </span><span class="hljs-attribute"><span class="hljs-tag"><span class="hljs-attr">port</span></span></span><span class="hljs-tag">=</span><span class="hljs-value"><span class="hljs-tag"><span class="hljs-string">"8080"</span></span></span><span class="hljs-tag"> </span><span class="hljs-attribute"><span class="hljs-tag"><span class="hljs-attr">protocol</span></span></span><span class="hljs-tag">=</span><span class="hljs-value"><span class="hljs-tag"><span class="hljs-string">"HTTP/1.1"</span></span></span><span class="hljs-tag"> </span><span class="hljs-attribute"><span class="hljs-tag"><span class="hljs-attr">connectionTimeout</span></span></span><span class="hljs-tag">=</span><span class="hljs-value"><span class="hljs-tag"><span class="hljs-string">"20000"</span></span></span><span class="hljs-tag"> </span><span class="hljs-attribute"><span class="hljs-tag"><span class="hljs-attr">redirectPort</span></span></span><span class="hljs-tag">=</span><span class="hljs-value"><span class="hljs-tag"><span class="hljs-string">"8443"</span></span></span><span class="hljs-tag"> /></span></span><div class="hljs-button signin" data-title="登陸後複製"></div></code></pre>tomcat
<p>connectionTimeout就是連接超時時間,單位是毫秒,默認就是20秒。</p> 原文地址:https://blog.csdn.net/shiyong1949/article/details/72845634 </div>服務器