java rmi重新连接客户端问题

java rmi重新连接客户端问题,java,rmi,Java,Rmi,我正在尝试开发一个简单的服务器/客户端程序usrinjavarmi。到目前为止,一切似乎都很正常,但唯一的问题是,当客户端退出并尝试重新连接时,会出现以下异常: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.ConnectException: Connection refused to host: 192.168.x.y; nested

我正在尝试开发一个简单的服务器/客户端程序usrinjavarmi。到目前为止,一切似乎都很正常,但唯一的问题是,当客户端退出并尝试重新连接时,会出现以下异常:

java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: 
    java.rmi.ConnectException: Connection refused to host: 192.168.x.y; nested exception is: 
    java.net.ConnectException: Connection refused: connect
为什么服务器第二次拒绝连接

这是我的密码

服务器:

public static void main(String[] args) {
    try {

        Naming.rebind("ChatServer", new ChatServerImpl());

        Naming.rebind("NotificationSource",  nsource);

        System.out.println("Chat Server is up and runnning!");

    } catch (Exception e) {
        System.err.println("Problem!!!!");
        e.printStackTrace();
    }
}
“聊天服务器”和“nsource”(nsource是静态的)是扩展“远程”接口的UnicastRemoteObject对象。(“ChatServer”和“NotificationInterface”)

客户

public static void main(String[] args) {

    String url_ChatServer = "rmi://localhost/ChatServer";
    String url_NotificationSource = "rmi://localhost/NotificationSource";

    try {

        ChatServer cs = (ChatServer) Naming.lookup(url_ChatServer);

        NotificationSourceInterface ns = (NotificationSourceInterface) Naming.lookup(url_NotificationSource);

        new Thread(new ChatClientImpl(cs,ns)).start();

    } catch (Exception e) {
        System.err.println("Problem ~Client");
        e.printStackTrace();
    }
}
我没有使用rmic,因为不再需要它(因为java 1.5)


thx

如果您在查找中得到该信息,则注册表已关闭。如果让它调用远程方法,则其JVM已退出