org.apache.catalina.connector.ClientAbortException: java.io.IOException: 您的主机中的软件中止了一个已建立的连接。

32 篇文章 0 订阅

问题

org.apache.catalina.connector.ClientAbortException: java.io.IOException: 您的主机中的软件中止了一个已建立的连接。

org.apache.catalina.connector.ClientAbortException: java.net.SocketException: Software caused connection abort: socket write error
	at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:410)
	at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:371)
	at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:435)
	at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:423)
	at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:91)
	at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:84)
	at org.apache.commons.io.IOUtils.write(IOUtils.java:631)
	at com.wei.utils.CreateZipAndDownload.CreateZipAndDownload(CreateZipAndDownload.java:68)
	at com.wei.service.impl.ArticleServiceImpl.download(ArticleServiceImpl.java:128)
	at com.wei.web.servlet.ArticleServlet.download(ArticleServlet.java:70)
	at com.wei.web.servlet.ArticleServlet.doGet(ArticleServlet.java:61)
	at com.wei.web.servlet.ArticleServlet.doPost(ArticleServlet.java:180)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at com.wei.web.filter.EncodingFilter.doFilter(EncodingFilter.java:29)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1082)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:623)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.net.SocketException: Software caused connection abort: socket write error
	at java.net.SocketOutputStream.socketWrite0(Native Method)
	at java.net.SocketOutputStream.socketWrite(Unknown Source)
	at java.net.SocketOutputStream.write(Unknown Source)
	at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:215)
	at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:480)
	at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:366)
	at org.apache.coyote.http11.InternalOutputBuffer$OutputStreamOutputBuffer.doWrite(InternalOutputBuffer.java:240)
	at org.apache.coyote.http11.filters.IdentityOutputFilter.doWrite(IdentityOutputFilter.java:84)
	at org.apache.coyote.http11.AbstractOutputBuffer.doWrite(AbstractOutputBuffer.java:192)
	at org.apache.coyote.Response.doWrite(Response.java:499)
	at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:405)
	... 36 more

org.apache.catalina.connector.ClientAbortException: java.net.SocketException: Software caused connection abort: socket write error

机翻:org.apache.catalina.connector.ClientAbortException:java.net.SocketException:软件导致连接中止:套接字写入错误

在这里插入图片描述

解决

Stack Overflow:https://stackoverflow.com/search?q=Software+caused+connection+abort%3A+socket+write+error

https://stackoverflow.com/questions/2126607/official-reasons-for-software-caused-connection-abort-socket-write-error?r=SearchResults

https://docs.microsoft.com/en-us/previous-versions/ms832256(v=msdn.10)?redirectedfrom=MSDN

https://community.oracle.com/thread/1691330

他人分析

1

程序运行正常,数据也没有出错,后台却老是报这个错误。在网上找了别人写的博客,这个问题的原因有几个:

①:服务器的并发连接数超过了其承载量,服务器会将其中一些连接Down掉;
②:客户关掉了浏览器,而服务器还在给客户端发送数据;
③:浏览器端按了Stop
④:用servlet的outputstream输出流下载图片时,当用户点击取消也会报这个错

花了些功夫最后找出来的原因是:用servlet的response.getOutputStream时,写回多个数据,而客户端没全部接收,可能会报下面这个错误。如:

服务器上写了两条数据

out.writeObject(“1”);

out.writeObject(“2”);

客户端只接收一条
in.readObject(url);

上面摘自:https://www.iteye.com/blog/asdzheng-1921858

2:tomcat超时?

在tomcat中出现这个错误是由于客户端在发送请求后,还没等服务器响应就断开了连接,有可能是因为网络原因,突然网断了,但是如果错误频繁出现的话,可能就是服务端的问题了。

tomcat中配置了一个连接超时时间connectionTimeout,如果在这个时间之后客户端还未得到服务器端的响应的话,就会主动断开连接,这样就会出现上述异常了,tomcat中默认的连接超时时间是20秒,我们一般最好设置为60秒,从而避免后台程序处理时间长导致连接断开。

解决方法:
可以通过设置tomcat下conf文件夹的server.xml文件,对请求连接数和请求超时时间进行设置。

<Connector port="8080" protocol="HTTP/1.1"   
              connectionTimeout="20000"   
              redirectPort="8443" acceptCount="500" maxThreads="400" />  
connectionTimeout以毫秒为单位,默认设置为20秒。通过修改该参数,可以修改tomcat的请求超时时间;

关于修改最大并发请求连接数,需要修改maxThreadsacceptCount两个参数,

其中,maxThreads的介绍如下:

The maximum number of request processing threads to be created by this Connector, which therefore determines the maximum number of simultaneous requests that can be handled. If not specified, this attribute is set to 200. If an executor is associated with this connector, this attribute is ignored as the connector will execute tasks using the executor rather than an internal thread pool.

此连接器要创建的请求处理线程的最大数目,从而确定可以处理的同时请求的最大数目。如果未指定,则此属性设置为200。如果执行器与此连接器关联,则忽略此属性,因为连接器将使用执行器而不是内部线程池执行任务。

acceptCount的介绍为:

The maximum queue length for incoming connection requests when all possible request processing threads are in use. Any requests received when the queue is full will be refused. The default value is 100.

当所有可能的请求处理线程都在使用时,传入连接请求的最大队列长度。当队列已满时收到的任何请求都将被拒绝。默认值为100。

所以两者的默认值分别是200和100,要调整Tomcat的默认最大连接数,可以增加这两个属性的值,并且使acceptCount大于等于maxThreads

摘自::https://blog.csdn.net/persistencegoing/article/details/88850767

3.mysql连接超时?

网上最多的还是mysql的8小时超时,根据他们所说的修改mysql的配置文件加入interactive_timeout=28800000 wait_timeout=28800000,然并卵,没用,依然没有解决问题。后面看到一篇关于spring+c3p0连接池配置的文章修改了自己连接池配置:

<!-- 指定连接池中保留的最大连接数. Default:15-->  
        <property name="maxPoolSize" value="${jdbc.maxPoolSize}"/>  
        <!-- 指定连接池中保留的最小连接数-->  
        <property name="minPoolSize" value="${jdbc.minPoolSize}"/>  
        <!-- 指定连接池的初始化连接数  取值应在minPoolSize 与 maxPoolSize 之间.Default:3-->  
        <property name="initPoolSize" value="${jdbc.initialPoolSize}"/>  
        <!-- 最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。 Default:0-->  
        <property name="maxIdleTime" value="${jdbc.maxIdleTime}"/>  
        <!-- 当连接池中的连接耗尽的时候c3p0一次同时获取的连接数. Default:3-->  
        <property name="acquireIncrement" value="${jdbc.acquireIncrement}"/>
        <!-- 每60秒检查所有连接池中的空闲连接.Default:0 -->  
        <property name="idleConnectionTestPeriod" value="${jdbc.idleConnectionTestPeriod}"/>  
jdbc.maxPoolSize=100
jdbc.minPoolSize=10
jdbc.initPoolSize=20
jdbc.maxIdleTime=120
jdbc.acquireIncrement=6
jdbc.idleConnectionTestPeriod=60

原文链接:https://blog.csdn.net/z842667166/article/details/54943845

我的

查了好多资料,总结如下

原因

This error can occur when the local network system aborts a connection, such as when WinSock closes an established connection after data retransmission fails (receiver never acknowledges data sent on a datastream socket).

当本地网络系统中止连接时,例如当WinSock在数据重新传输失败后关闭已建立的连接时(接收器从不确认在数据流套接字上发送的数据),可能会发生此错误。

解决

Check the following: 1. Ping the remote host you were connected to. If it doesn’t respond, it might be off-line or there might be a network problem along the way. If it does respond, then this problem might have been a transient one (so you can reconnect now), or the server application you were connected to might have terminated (so you might not be able to connect again). 2. Ping a local host to verify that your local network is still functioning (if on a serial connection, see next step). 3. Ping your local router address. If you are on a serial connection, your local router is the IP address of the host you initially logged on to using SLIP or PPP. 4. Ping a host on the same subnet as the host you were connected to (if you know of one). This will verify that the destination network is functioning. 5. Use the tracert command at the command prompt to determine the path to the host you were connected to. This won’t reveal too much unless you know the router addresses at the remote end, but it might help to identify if the problem is somewhere along the way.
检查以下各项:1。Ping连接到的远程主机。如果它不响应,可能是离线的,也可能是一路上的网络问题。如果它确实响应,则此问题可能是暂时的(因此您现在可以重新连接),或者您连接到的服务器应用程序可能已终止(因此您可能无法再次连接)。2。Ping本地主机以验证本地网络是否仍在运行(如果是串行连接,请参阅下一步)。三。Ping本地路由器地址。如果您使用串行连接,则本地路由器是您最初使用SLIP或PPP登录到的主机的IP地址。四。Ping与您连接的主机位于同一子网上的主机(如果您知道其中一个)。这将验证目标网络是否正常工作。5个。在命令提示下使用tracert命令确定连接到的主机的路径。除非您知道远程端的路由器地址,否则这不会透露太多信息,但它可能有助于确定问题是否在某个地方。

https://docs.microsoft.com/en-us/previous-versions/ms832256(v=msdn.10)?redirectedfrom=MSDN

  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值