在Ajax请求时提示java.net.SocketException: Connection reset by peer: socket write error错误而且不能返回数据信息
ClientAbortException: java.net.SocketException: Connection reset by peer: socket write error
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:366)
at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:352)
at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:392)
at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:381)
at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:89)
at org.apache.catalina.servlets.DefaultServlet.copy(DefaultServlet.java:1784)
at org.apache.catalina.servlets.DefaultServlet.serveResource(DefaultServlet.java:874)
at org.apache.catalina.servlets.DefaultServlet.doGet(DefaultServlet.java:376)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.cabletech.commons.web.SystemFilter.doFilter(SystemFilter.java:33)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:747)
at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:432)
at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:347)
at org.apache.coyote.http11.InternalOutputBuffer$OutputStreamOutputBuffer.doWrite(InternalOutputBuffer.java:770)
at org.apache.coyote.http11.filters.IdentityOutputFilter.doWrite(IdentityOutputFilter.java:118)
at org.apache.coyote.http11.InternalOutputBuffer.doWrite(InternalOutputBuffer.java:580)
at org.apache.coyote.Response.doWrite(Response.java:560)
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:361)
... 26 more
改前AJAX代码:
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
function getTaskSubline() {
createXMLHttpRequest();
var linelevel = document.getElementById("linelevel").value;
if(" "==linelevel){
return ;
}
var url="/WebApp/plan.do?method=getTaskSublinePoint&value="+linelevel;
xmlHttp.open("get", url, false);
xmlHttp.onreadystatechange = startCallback;
xmlHttp.send(null);
}
function startCallback() {
if (xmlHttp.readyState == 4) {
var left = document.getElementById("task");
left.innerHTML = xmlHttp.responseText;
}
}
</script>
改后Ajax代码:
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
function getTaskSubline() {
createXMLHttpRequest();
var linelevel = document.getElementById("linelevel").value;
if(" "==linelevel){
return ;
}
var url="/WebApp/plan.do?method=getTaskSublinePoint&value="+linelevel;
xmlHttp.open("post", url, false);
xmlHttp.onreadystatechange = startCallback;
xmlHttp.send(null);
}
function startCallback() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) { // 信息已经成功返回,开始处理信息
var htmltree = xmlHttp.responseText;
var taskdiv = document.getElementById("taskdiv");
taskdiv.innerHTML = htmltree;
} else { //页面不正常
alert("您所请求的页面有异常。");
}
}
}
</script>
前后代码比较也没有什么不同的地方,但是竟然不提上Connection reset by peer: socket write error错误了。
分享到:
相关推荐
* Connection reset by peer:Connection reset by peer 是一种特殊的 SocketException,它发生在客户端和服务器端之间的连接断开后,导致连接的一端继续发送数据,引发该异常。 实践经验 通过实践经验,我们可以...
**Modbus TCP客户端和服务器示例** 在工业自动化和物联网(IoT)领域,Modbus是一种广泛使用的通信协议,它允许设备之间进行简单的数据交换。本文将深入探讨Modbus TCP,这是一种在网络环境中运行的Modbus变体,尤其...
connection reset by peer问题总结及解决方案 1.服务器的并发连接数超过了其承载量,服务器会将其中一些连接关闭 如果知道实际连接服务器的并发客户端数并没有超过服务器的承载量,则有可能是中了病毒或者木马,引起...
java.net.SocketException: Connection reset by peer: Socket write error 该异常可能发生在客户端和服务器端,原因是因为一端的 Socket 被关闭,而另一端继续发送数据。解决方法是确保在关闭连接前完成所有的数据...
1. 使用 Oracle 数据库,大于 4k 的附件上传有问题,会报错 java.sql.SQLException: Connection reset by peer: socket write error。 解决办法是在插入 BLOB 字段值时,要先用 SELECT BLOBCOL FROM TABLENAME FOR ...
java.net.SocketException: Connection reset by peer: Socket write error 此异常通常出现在客户端尝试向服务器写入数据时突然断开连接的情况。这种现象的原因可能是远程服务器突然关闭了连接,或者客户端发送的...
根据提供的部分内容,“java.sql.SQLException: Already closed.”和“java.sql.SQLException: I/O exception: Connection reset by peer: socket write error”这类异常通常与数据库连接管理不当有关,如连接超时、...
在文件上传或下载时,可能会遇到`SocketException: Connection reset by peer: socket write error`的异常。这个异常通常是由于网络中断或者客户端提前关闭连接引起的。在开发中,可以通过捕获异常并进行相应的处理...
4. **java.net.SocketException: (Connection reset 或 Connect reset by peer: Socket write error)** 这两种异常都表示连接已断开。可能的原因是一端关闭了Socket,而另一端仍在尝试读写。处理这类异常需要检测到...
except ConnectionResetError: print('Connection reset by peer.') ``` 六、多线程或异步IO 在处理多个并发连接时,可以使用多线程或多进程,或者利用Python的asyncio库进行异步I/O。例如,使用asyncio创建一个...