0

我正在使用 RMI 客户端,但是当我尝试从除 localhost 之外的任何机器连接到它时,它会收到拒绝的连接堆栈跟踪。我确认我的防火墙已关闭。我还需要做什么?这是我的代码

public class FrontManagerClient {

    boolean state;
    String command;
    String value;

    public FrontManagerClient(String cmd,String value) {
        this.command=cmd;
        this.value=value;
    }

    public  boolean getCommand() throws RemoteException, NotBoundException, MalformedURLException{

        FrontPanelManagerIntrface f=(FrontPanelManagerIntrface)Naming.lookup("lookup=//localhost//frontPanelRequestControllerService");
        state=f.Communicate(command, value);
        return state;
    }

    public static void main(String[] args) throws RemoteException, NotBoundException, MalformedURLException {
        FrontManagerClient f = new FrontManagerClient("Password_Enter", "admin");
        System.out.println(""+f.getCommand());
    }
}

当我运行服务器并运行客户端时,它会显示此错误消息

 Exception in thread "main" java.rmi.ConnectException: Connection refused to host: 10.96.28.6; nested exception is: 
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:340)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Naming.java:101)
at doormanager.FrontManagerClient.getCommand(FrontManagerClient.java:30)
at doormanager.FrontManagerClient.main(FrontManagerClient.java:37)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at java.net.Socket.<init>(Socket.java:425)
at java.net.Socket.<init>(Socket.java:208)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:146)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
... 7 more

Java 结果:1

4

1 回答 1

1

主机 10.96.28.6 上没有运行 RMI 注册表,或者您没有修复防火墙。

于 2013-07-06T21:26:37.700 回答