Java RMI连接拒绝

时间:2019-01-02 08:23:13

标签: java rmiio

我确实收到以下错误:

2019-01-02 16:14:22.789  INFO 3131 --- [           main] com.dbs.rmg.cli.App                      : Started App in 4.619 seconds (JVM running for 5.227)
2019-01-02 16:14:22.907  INFO 3131 --- [)-10.91.xxx.xxx] o.h.h.i.QueryTranslatorFactoryInitiator  : HHH000397: Using ASTQueryTranslatorFactory
2019-01-02 16:14:23.158  INFO 3131 --- [)-10.91.xxx.xxx] c.h.rmiio.exporter.RemoteStreamExporter  : Using stream exporter com.healthmarketscience.rmiio.exporter.DefaultRemoteStreamExporter
2019-01-02 16:14:33.177  WARN 3131 --- [           main] c.h.rmiio.RemoteInputStreamClient        : Retry for caller com.healthmarketscience.rmiio.RemoteInputStreamWrapper$1@2100d047 giving up!
java.rmi.ConnectException: Connection refused to host: 10.91.xxx.xxx; nested exception is:
        java.net.ConnectException: Connection refused (Connection refused)
        at java.rmi/sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
        at java.rmi/sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:209)
        at java.rmi/sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:196)
        at java.rmi/sun.rmi.server.UnicastRef.invoke(UnicastRef.java:129)
        at java.rmi/java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:209)
        at java.rmi/java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:161)
        at com.sun.proxy.$Proxy82.usingGZIPCompression(Unknown Source)
        at com.healthmarketscience.rmiio.RemoteInputStreamWrapper$1.call(RemoteInputStreamWrapper.java:56)
        at com.healthmarketscience.rmiio.RemoteInputStreamWrapper$1.call(RemoteInputStreamWrapper.java:53)
        at com.healthmarketscience.rmiio.RemoteRetry.callImpl(RemoteRetry.java:153)
        at com.healthmarketscience.rmiio.RemoteRetry.call(RemoteRetry.java:273)
        at com.healthmarketscience.rmiio.RemoteRetry.call(RemoteRetry.java:214)
        at com.healthmarketscience.rmiio.RemoteInputStreamWrapper.usingGZIPCompression(RemoteInputStreamWrapper.java:52)
        at com.healthmarketscience.rmiio.RemoteInputStreamWrapper.usingGZIPCompression(RemoteInputStreamWrapper.java:46)
        at com.healthmarketscience.rmiio.RemoteInputStreamClient.wrap(RemoteInputStreamClient.java:80)
        at com.healthmarketscience.rmiio.RemoteIteratorClient.initialize(RemoteIteratorClient.java:95)
        at com.healthmarketscience.rmiio.RemoteIteratorClient.hasNext(RemoteIteratorClient.java:149)
        at com.dbs.rmg.utils.Pipe$6.hasNext(Pipe.java:178)
        at com.dbs.rmg.cli.App.run(App.java:92)

我能够通过命令execute存储我的代码,但是它被卡在下面,

public static <T extends Remote> T getService(Class<T> cls, String IP, int PORT) {
        String url = RmiConfig.buildRmiUrl(PORT, cls.getSimpleName());

        try {
            JobService jobService = new JobServiceImpl();

            System.setProperty("java.rmi.server.hostname", IP);
            LocateRegistry.createRegistry(PORT);
            String location = "//localhost:" + PORT + "/JobService";
            Naming.rebind(location, jobService);

            return cls.cast(Naming.lookup(url));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

我认为绑定成功,因为它可以返回,但是最后它卡在textIterator.hasNext()上,我不知道我到底做了什么错误。

@Override
    public void run(String... args) throws Exception {
        JobService jobService = Controller.getJobService(this.IP, this.PORT);

        try {
            Iterator<String> textIterator = Pipe.iterator(jobService.submitAndStreamError(fileType, param, queueName, maxRetry));

            String defaultRetry = "0";

            while (textIterator.hasNext()) {
                defaultRetry = textIterator.next();

                System.out.println(defaultRetry);
            }

            System.exit(Integer.parseInt(defaultRetry));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

当我迷失了调试的想法时,任何人都可以给出一些提示。

0 个答案:

没有答案