Common reasons for Connection reset by peer:

Source: Internet
Author: User
Tags connection reset

common causes of Connection reset by peer :


1) The number of concurrent connections to the server exceeds its capacity, and the server shuts down some of the connections;

If you know that the actual number of concurrent clients connected to the server does not exceed the load of the server, it is possible that a virus or trojan, causing network traffic anomalies. You can use Netstat-an to view network connections.


2) The client has turned off the browser and the server is sending data to the client;


3) The browser side presses stop;

These two situations generally do not affect the server. However, if the exception information is not handled specifically, it is possible to duplicate the exception in the server's log file, causing the server log file too large to affect the server's operation. You can use Try...catch to catch the exception to the part that caused the exception, and then do not output or just output a single prompt message, avoid using e.printstacktrace (), and output all exception information.


4) firewall problems;

If the network connection through the firewall, and the firewall generally has a time-out mechanism, when the network connection does not transfer data for a long time, the TCP session will be closed, read and write after the shutdown, will cause an exception. If you turn off the firewall, the problem is resolved, you need to reconfigure the firewall, or you write your own program to implement TCP long connections. To implement TCP long connection, you need to define the heartbeat protocol, every time, send a heartbeat protocol, both sides maintain the connection.


5) The buffer problem of JSP.

JSP page Default cache is 8k, when the JSP page data is relatively large, it is possible that the JSP is not completely passed to the browser. The buffer size can then be adjusted appropriately. <%@ page buffer= "100k"%>


Common network exceptions (go from http://www.cnblogs.com/kaixin110/archive/2008/04/11/1148671.html):


The 1th exception is java.net.BindException:Address already in Use:jvm_bind. This exception occurs when the server side operates on a new ServerSocket (port is an integer value of 0,65536). The exception is due to the fact that a port is already being started and is listening. At this point, with the Netstat–an command, you can see a port with a listending status. Just find an unoccupied port to solve this problem.


The 2nd exception is Java.net.ConnectException:Connection Refused:connect. This exception occurs when the client makes a new Socket (IP, Port) operation because the exception occurs because either the machine with the IP address cannot be found (that is, the current machine does not exist to the specified IP route), or the IP exists, but the specified port is not found for listening. This problem occurs, first check the client's IP and port is wrong, if it is correct to ping the server from the client to see if it can ping, if you can ping (the service server to ping off the need for another method), the server-side listening to the specified port program is started, This will certainly solve the problem.


The 3rd exception is the Java.net.SocketException:Socket is closed, which can occur on both the client and the server. The reason for the exception is that you have actively closed the connection (called the Close method of the socket) and read and write the network connection.


The 4th exception is java.net.SocketException: (Connection reset or Connect reset by Peer:socket write error). This exception can occur on both the client and the server side, causing the exception to be two, the first of which is if the socket on one end is turned off (or closed by an unexpected exit), the other end still sends the data, and the first packet that is sent throws the exception (Connect reset by Peer). The other is one end exiting, but the connection is not closed when exiting, and the other end throws the exception if the data is read from the connection (Connection reset). The simple thing is that the read and write operations are caused by the disconnection of the connection.


The 5th exception is the Java.net.SocketException:Broken pipe. This exception can occur on both the client and the server. In the first case of the 4th exception (that is, after you throw socketexcepton:connect reset by Peer:socket write error), the exception is thrown if you continue to write the data. The solution to the first two exceptions is to first ensure that all network connections are closed before the program exits, followed by detection of the other's closed connection operation, and that the other person closes the connection after closing the connection.


Common reasons for Connection reset by peer:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.