<< java URLConnection and timeout and non-blocking io | 首页 | Maven2 一个完整的pom.xml >>

What does the exception "java.net.SocketException: Connection reset by peer" mean? How can this be avoided?

It usually happens when the connection was reset by the peer -- that is, when the client unexpectedly closed the socket. This happens when the user clicks "stop", or "reload", or "back", or enters a new URL, or closes his Internet connection, while a resource is still being downloaded (before your server gets to close its socket). This is normal behavior and you shouldn't worry about it.

The server is reporting "connection reset by peer" in the middle of a request. That means one of the following things:

  • The browser started a request and the user pressed STOP.
  • The browser started an request in one frame and JavaScript on another frame told it to go somewhere else (which has the same effect as a user pressing STOP).
  • You have a meta refresh reload someplace that is firing so fast that the previous request hasn't had a chance to complete yet. The five second periodicity makes me pretty suspicious of this.
  • You have some network component in between (a router or proxy) that is misbehaving.
  • You have some completely separate connection attempts going on that are disobeying the HTTP protocol (such as doing a telnet connection to port 8080 and then disconnecting).
标签 : ,



发表评论 发送引用通报