`

Connection reset by peer: socket write error

阅读更多
在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错误了。
分享到:
评论
1 楼 congjl2002 2008-12-30  
我最近也遇到这个问题,难道是因为页面没有加载完成造成的?

还有你如果不把set改成post还会出异常吗?

相关推荐

    java.net.SocketException Connection reset 解决方法

    * Connection reset by peer:Connection reset by peer 是一种特殊的 SocketException,它发生在客户端和服务器端之间的连接断开后,导致连接的一端继续发送数据,引发该异常。 实践经验 通过实践经验,我们可以...

    Modbus TCP客户端和服务器示例

    **Modbus TCP客户端和服务器示例** 在工业自动化和物联网(IoT)领域,Modbus是一种广泛使用的通信协议,它允许设备之间进行简单的数据交换。本文将深入探讨Modbus TCP,这是一种在网络环境中运行的Modbus变体,尤其...

    Java Socket常见异常处理

    4. **java.net.SocketException: (Connection reset 或 Connect reset by peer: Socket write error)** 这两种异常都表示连接已断开。可能的原因是一端关闭了Socket,而另一端仍在尝试读写。处理这类异常需要检测到...

    python中关于网络socket使用实例,供大家参考使用

    except ConnectionResetError: print('Connection reset by peer.') ``` 六、多线程或异步IO 在处理多个并发连接时,可以使用多线程或多进程,或者利用Python的asyncio库进行异步I/O。例如,使用asyncio创建一个...

    J2EE应用开发问题总结及最佳实践.pdf

    1. 使用 Oracle 数据库,大于 4k 的附件上传有问题,会报错 java.sql.SQLException: Connection reset by peer: socket write error。 解决办法是在插入 BLOB 字段值时,要先用 SELECT BLOBCOL FROM TABLENAME FOR ...

Global site tag (gtag.js) - Google Analytics