开发者

Error starting Custom JMX Server on 0.0.0.0

开发者 https://www.devze.com 2023-02-11 04:58 出处:网络
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

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)
开发者_JAVA百科        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)


Found a note which might help you:

With Sun's JMX Remote JMX RI, the hostname/ip-addr segment is not used to limit the target IP address/name, as it should. It must just match any valid IP address/name for this host (including localhost or 127.0.0.1), and it will then listen to IPADDR_ANY. You will have to do custom coding (or use an IP filtering or firewall product) to limit the listen addresses.

So it looks like you could just replace 0.0.0.0 with localhost 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).

0

精彩评论

暂无评论...
验证码 换一张
取 消