2 Replies Latest reply on Feb 11, 2015 11:21 PM by EJP

    SocketException: Connection reset by peer: socket write error RMI Server Class

    e54b6fe1-20e3-4917-ac8f-b8b82798ca3c

      I am new to distributed application development. Got a project from university of making a chess game which can be played over the LAN. I started learning RMI to complete his project. I am using Eclipse and RMI plugin from genday. When I try to load the server class after starting registry. It doesn't throw any error exception in the server class console but server class stops before completion.

       

      import java.rmi.RemoteException;
      import java.rmi.registry.LocateRegistry;
      import java.rmi.registry.Registry;
      
      public class Server {
      
          public static void main(String args[]){
              try{
                  PrintString stub = new PrintStringImpl();
                  Registry registry = LocateRegistry.getRegistry();
                  System.out.println(registry);
                  registry.rebind("PrintString", stub);
                  System.out.println("Started");
              }catch(RemoteException ex){
                  ex.printStackTrace();
              }
          }
      }
      
      

       

      This Sever class print registry details before registry.rebind() and crashed at the same point without printing "Started". I displayed another console which is "C:\Program Files\Java\jdk\bin\rmiregistry.exe (localhost: 1099)". it is showing error like

       

      
      Exception dispatching call to [0:0:0, 0] in thread "RMI TCP Connection(2)-192.168.3.106" at Wed Nov 05 09:52:03 PKT 2014:
      java.rmi.UnmarshalException: error unmarshalling call header; nested exception is: 
          java.net.SocketException: Connection reset by peer: socket write error
          at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
          at sun.rmi.transport.Transport$1.run(Unknown Source)
          at sun.rmi.transport.Transport$1.run(Unknown Source)
          at java.security.AccessController.doPrivileged(Native Method)
          at sun.rmi.transport.Transport.serviceCall(Unknown Source)
          at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
          at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
          at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
          at java.lang.Thread.run(Unknown Source)
      Caused by:java.net.SocketException: Connection reset by peer: socket write error
          at java.net.SocketOutputStream.socketWrite0(Native Method)
          at java.net.SocketOutputStream.socketWrite(Unknown Source)
          at java.net.SocketOutputStream.write(Unknown Source)
          at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
          at java.io.BufferedOutputStream.flush(Unknown Source)
          at java.io.ObjectOutputStream$BlockDataOutputStream.flush(Unknown Source)
          at java.io.ObjectOutputStream.flush(Unknown Source)
          at sun.rmi.transport.StreamRemoteCall.releaseOutputStream(Unknown Source)
          at sun.rmi.server.UnicastServerRef.oldDispatch(Unknown Source)
          ... 11 more
      

       

      As far as, I am tackling with this problem by restarting laptop, and after restart it again works fine. There is no firewall installed and working on my computer. Any help would be greatly appreciated.