java.net.ConnectException: Connection refused solution to the problem

  • 2020-05-19 04:51:05
  • OfStack

Abnormal Socket

Client exception


java.net.ConnectException: Connection refused: connect . 

This exception occurs when the client is performing an new Socket(ip, port) operation because either the machine with the ip address cannot be found (that is, from the current machine does not exist to the specified ip route), or the ip exists but cannot find the specified port to listen on. If this problem occurs, first check whether the client side ip and port are miswritten. If it is correct, check whether the client side ping1 server can access ping. If it can access ping (if the server side can disable ping, another method is needed), then check whether the program listening on the specified port on the server side is started.

java.net.SocketException: Socket is closed

The common reason for this is that after you have actively closed the connection (by calling Socket's close method), you can read and write to the network connection.

SocketException: (Connection reset or Connect reset by peer:Socket write error)

The first is that if the first end of Socket is shut down (or actively shut down or shut down due to an exception exit), the other end still sends data, and the first packet sent raises the exception (Connect reset by peer). The other end exits without closing the connection when it exits, and the other end throws the exception if it is reading data from the connection (Connection reset). In simple terms, this is caused by read and write operations after the connection is broken.

java. net. SocketException: Broken pipe.

Throw this exception if you continue writing data after SocketExcepton:Connect reset by by write error

(it hasn't been measured yet.)

java. net. BindException: Address already in use: JVM_Bind.

This exception occurs on the server side when an operation new ServerSocket(port) (port is an integer value of 0,65536) is performed. The reason for the exception is that a port like port1 has been started and is being monitored. At this point, you can see a port in the Listending state using the netstat and an commands. All you need to do is find a port that is not occupied.

java.net.SocketException: Socket is closed

(same as client)

SocketException: (Connection reset or Connect reset by peer:Socket write error)

(same as client)

java. net. SocketException: Broken pipe.

Thank you for reading, I hope to help you, thank you for your support of this site!


Related articles: