在 0.0.0.0 上启动自定义 JMX 服务器时出错
我使用以下代码启动我们的 JMX 服务器:
Integer port = 8291;
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://0.0.0.0:"+ (port+100) +"/jndi/rmi://0.0.0.0:"+ port +"/jmxrmi");
在我们的应用程序启动时,我们得到:
Caused by: java.rmi.ConnectException: Connection refused to host: 0.0.0.0; nested exception is:
java.net.ConnectException: Connection refused
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
at com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:120)
... 53 more
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:193)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:525)
at java.net.Socket.connect(Socket.java:475)
at java.net.Socket.<init>(Socket.java:372)
at java.net.Socket.<init>(Socket.java:186)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterS
这在 Windows 中有效,但在 Linux 上失败。没有任何内容与 8291 绑定。(我使用 netstat -anp
验证了这一点)
有人知道为什么会失败吗?
供参考。由于防火墙的原因,我们正在启动自定义 JMX 服务器(请参阅 此处解释原因)
I am starting our JMX server using the following code:
Integer port = 8291;
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://0.0.0.0:"+ (port+100) +"/jndi/rmi://0.0.0.0:"+ port +"/jmxrmi");
On our application startup we are getting:
Caused by: java.rmi.ConnectException: Connection refused to host: 0.0.0.0; nested exception is:
java.net.ConnectException: Connection refused
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
at com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:120)
... 53 more
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:193)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:525)
at java.net.Socket.connect(Socket.java:475)
at java.net.Socket.<init>(Socket.java:372)
at java.net.Socket.<init>(Socket.java:186)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterS
This works in windows but fails on linux. There is nothing bound to 8291. (I verified this with a netstat -anp
)
Does anybody know why this is failing?
FYI. We are starting a custom JMX server because of the firewall (see here for explanation why)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到一条可能对您有帮助的注释:
因此,您似乎只需将
0.0.0.0
替换为localhost
,它仍然会侦听所有网络接口。顺便说一句,我尝试了您的代码进行了此更改,但现在我得到了另一个异常(尽管是一个不同的异常)。
Found a note which might help you:
So it looks like you could just replace
0.0.0.0
withlocalhost
and it would still listen on all network interfaces.BTW, I tried your code with this change, but now I get another exception (a different one though).