沪江日语视频 百度网盘:java.net.SocketException: Connection reset by peer: socket write error

来源:百度文库 编辑:偶看新闻 时间:2024/05/05 14:54:36

在网上查找了了下原因,大概归结为:
ClientAbortException: java.net.SocketException: Connection reset by peer: socket write error的原因是由于处理http连接时,正在输出内容时,用户关闭了IE,会出现一个"ClientAbortException",属于I/O处理中出现的一个异常,应用服务器应该会捕捉。
Connection reset by peer的原因:
经常出现的Connection reset by peer: 原因可能是多方面的,不过更常见的原因是:
①:服务器的并发连接数超过了其承载量,服务器会将其中一些连接Down掉;
②:客户关掉了浏览器,而服务器还在给客户端发送数据;
③:浏览器端按了Stop

多人都说是客户端造成的,没有办法控制,而且后台会记录这个异常,日志也会疯狂爆满,时间长了,肯定会DOWN掉的.
本人觉得大多数可能是第二条问题的原因引起的,即大多数浏览器阻止了窗口的弹出,相当于客户关掉了浏览器,可等效于浏览器端按了Stop ,而这时服务器端还在给客户端发送数据,所以产生了上异常,经过本人的测试,发现只需将网站地址(或本机地址)加入"受信任的站点"即可解决问题,因为这样设置了以后,浏览器就不会阻止窗口的弹出了,这样浏览器就会等到服务器端发送完数据后再进行下面的动作.因而异常就不会发生了.
大概设置方式如下:"工具->internet(选项..)->安全->受信任的站点->站点",将地址加入即可.

转载:http://blog.csdn.net/lupeng0527/archive/2010/09/03/5861537.aspx

自已找到的新的答案:
  1. When user make a request, and suddenly browser get closed by user accidentally or due to browser crash
  2. When user make a request, and browser closes the http connection automatically due to exceeded content length size
  3. When user make a request, and presses the stop button
  4. But surprisingly, there is one more reason which may cause this  problem. This is more unpredictable and very difficult to identify as well, that is problem with firewall.  When googled, I founded people complaining about firewall closing database connection automatically.  On top of this I am also not getting proper java exception stacktrace to track the error and fix.

    To elaborate more on firewall issue, the error is more TCP/IP connection level error where database is closed by the firewall after database connection are idle for certain time or certain db connection length. Possibility is that there is a statefull firewall which is closing database connections after certain time limit. I am still in the process of identifying what could be the real problem. Once I found real probelm and solution, I will post it in here. If any one know the solutions, please post it in the comments section. Thank you.

参考:http://www.ramraje.com/java-errors-solutions/javanetsocketexception-connection-reset-by-peer-socket-write-error/

另其它的答案:
    Well, the problem is that your server is closing you socket in the server side.

It is not necessarily an error. It all depends on your server protocol.

I am sure your server is performing a task or service for you. Now, if the protocol of the server establishes that every service requires a new socket, after serving your socket it will close the communication, and wait for another task.

You must understand your server protocol, that is, the way you must format the information through the wire so that your server and your client understand each other. That might be the problem.

However, there is a chance that the server is actually closing your socket unexpectedly. Maybe the server side can offer you some logging information about why the socket was closed.

I hope this helps!参考:http://www.coderanch.com/t/278027/Streams/java/Connection-reset-peer-socket-write