本文介绍了强制RMIService与特定IP地址绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用在端口4099上运行的Spring RMIServiceExporter实现了RMIService。当我启动我的Jboss时,RMI服务被绑定到0.0.0.0:4099而不是127.0.0.1:4099。我尝试了不同的参数

  -Djava.rmi.server.hostname = 127.0.0.1 
-Djava.rmi.server .hostname = localhost
-Djava.rmi.server.hostname = localhost.localdomain以及
-Djava.net.preferIPv4Stack = true参数。
用-b 127.0.0.1开始Jboss

它总是被绑定到 0.0.0.0:4099 。我用它来检查

 > netstat -anp | grep 4099 

> TCP 0.0.0.0:4099 0.0.0.0:0 LISTENING

以下是我的实现:

  RmiServiceExporter rmiServiceExporter = new RmiServiceExporter(); 
rmiServiceExporter.setService(this);
rmiServiceExporter.setServiceName(MyService);
rmiServiceExporter.setServiceInterface(MyServiceManager.class);
rmiServiceExporter.setRegistryPort(4099);
rmiServiceExporter.afterPropertiesSet();


解决方案

  1. java.rmi.server.hostname 与设置bind-address无关,我不确定它与Spring RMI有什么关系。它是 java.rmi 包的一个功能。


  2. <$>中显示的侦听端口c $ c> netstat 输出是注册表端口,不一定是服务器正在侦听的端口。


您似乎必须定义自己的 RMIServerSocketFactory ,它可以根据需要创建 ServerSockets 。 / p>

I implemented RMIService using Spring RMIServiceExporter running at port 4099. When I start my Jboss , RMI Service is getting bonded to 0.0.0.0:4099 instead of 127.0.0.1:4099. I tried different parameters

-Djava.rmi.server.hostname=127.0.0.1
-Djava.rmi.server.hostname=localhost
-Djava.rmi.server.hostname=localhost.localdomain along with
-Djava.net.preferIPv4Stack=true parameter.
Started Jboss with -b 127.0.0.1

Its always getting bonded to 0.0.0.0:4099. I check it using

>netstat -anp | grep 4099

>TCP    0.0.0.0:4099           0.0.0.0:0              LISTENING

Here is my implementation:

    RmiServiceExporter rmiServiceExporter = new RmiServiceExporter();
    rmiServiceExporter.setService(this);
    rmiServiceExporter.setServiceName("MyService");
    rmiServiceExporter.setServiceInterface(MyServiceManager.class);
    rmiServiceExporter.setRegistryPort(4099);
    rmiServiceExporter.afterPropertiesSet();
解决方案
  1. java.rmi.server.hostname has nothing to do with setting the bind-address, and I'm not sure it has anything to do with Spring RMI either. It is a feature of the java.rmi package.

  2. The listening port shown in the netstat output is the Registry port, not necessarily the port your server is listening on.

It appears you will have to define your own RMIServerSocketFactory that creates ServerSockets bound as you wish.

这篇关于强制RMIService与特定IP地址绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-10 21:02