Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Saturday, October 1, 2016

When is

When is "java.io.IOException:Connection reset by peer" thrown?


    25/Dec/2011 13:37:39 ERROR GServerHandler       - java.io.IOException: Connection reset by peer  java.io.IOException: Connection reset by peer          at sun.nio.ch.FileDispatcher.read0(Native Method)          at sun.nio.ch.SocketDispatcher.read(Unknown Source)          at sun.nio.ch.IOUtil.readIntoNativeBuffer(Unknown Source)          at sun.nio.ch.IOUtil.read(Unknown Source)          at sun.nio.ch.SocketChannelImpl.read(Unknown Source)          at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:323)          at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:282)          at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:202)          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)          at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)          at java.lang.Thread.run(Unknown Source)  

This log is from a game server implemented using netty. What can cause this exception ?

Answer by BalusC for When is "java.io.IOException:Connection reset by peer" thrown?


java.io.IOException: Connection reset by peer

The other side has abruptly aborted the connection in midst of a transaction. That can have many causes which are not controllable from the server side on. E.g. the enduser decided to shutdown the client or change the server abruptly while still interacting with your server, or the client program has crashed, or the enduser's internet connection went down, or the enduser's machine crashed, etc, etc.

Answer by EJP for When is "java.io.IOException:Connection reset by peer" thrown?


To expand on BalusC's answer, any scenario where the sender continues to write after the peer has stopped reading and closed its socket will produce this exception. In other words, an application protocol error. For example, if you write something to the peer that the peer doesn't understand, and then it closes its socket in protest, and you then continue to write, the peer's TCP stack will issue an RST, which results in this exception and message at the sender.

Answer by Ngoc Dao for When is "java.io.IOException:Connection reset by peer" thrown?


java.io.IOException in Netty means your game server tries to send data to a client, but that client has closed connection to your server.

And that exception is not the only one! There're several others. See BadClientSilencer in Xitrum. I had to add that to prevent those errors from messing my log file.

Answer by Eugene Chung for When is "java.io.IOException:Connection reset by peer" thrown?


I think this should be java.net.SocketException as its definition is stated for a TCP error.

/**   * Thrown to indicate that there is an error in the underlying    * protocol, such as a TCP error.    *   * @author  Jonathan Payne   * @version %I%, %G%   * @since   JDK1.0   */  public   class SocketException extends IOException {  

Answer by Appz for When is "java.io.IOException:Connection reset by peer" thrown?


For me useful code witch help me was http://rox-xmlrpc.sourceforge.net/niotut/src/NioServer.java

// The remote forcibly closed the connection, cancel

// the selection key and close the channel.

    private void read(SelectionKey key) throws IOException {              SocketChannel socketChannel = (SocketChannel) key.channel();                // Clear out our read buffer so it's ready for new data              this.readBuffer.clear();                // Attempt to read off the channel              int numRead;              try {                  numRead = socketChannel.read(this.readBuffer);              } catch (IOException e) {                  // The remote forcibly closed the connection, cancel                  // the selection key and close the channel.                  key.cancel();                  socketChannel.close();                  return;              }                if (numRead == -1) {                  // Remote entity shut the socket down cleanly. Do the                  // same from our end and cancel the channel.                  key.channel().close();                  key.cancel();                  return;              }  ...  

Answer by Vimalkumar Natarajan for When is "java.io.IOException:Connection reset by peer" thrown?


There are lot of factors , first see whether server returns the result, then check between server and client.

rectify them from server side first,then check the writing condition between server and client !

server side rectify the time outs between the datalayer and server from client side rectify the time out and number of available connections !


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.