I use the -Djava.rmi.server.hostname=localhost option to make rmi listen on localhost only, but netstat shows the socket is listening on 0.0.0.0.
The strange thing is that the RMI RenewClean thread shows its using localhost. E.g. RMI RenewClean-[localhost:59357]
I assumed that if I set -Djava.rmi.server.hostname=localhost it should only be listening on 127.0.0.1
Am I misunderstanding what java.rmi.server.hostname controls?
I assumed that if I set -Djava.rmi.server.hostname=localhost it should only be listening on 127.0.0.1
No.
Am I misunderstanding what java.rmi.server.hostname controls?
Yes. java.rmi.server.hostname
has nothing whatsoever to do with what IP address the remote object listens on. That is determined by the RMIServerSocketFactory.
To correct the misquotation from my book in another answer (subsequently deleted):
java.rmi.server.hostname:
Hostname string; default value is the local host's IP address in "dotted-quad" format ... which is embedded into remote stubs created by this JVM when remote objects are exported. This can be used to control the effective IP address of RMI servers exported by multi-homed hosts. This property is read exactly once in the life of the JVM.[1]
To expand on that, it can also be used to control the effective IP address (as seen by clients) of RMI servers exported by hosts that are behind NAT devices. It doesn't necessarily have anything to do with the local host, e.g. in NAT situations, and it can be either a hostname, a dotted-quad IPv4 address, or an IPv6 address.
[1] Pitt & McNiff, java.rmi, The Remote Method Invocation Guide, Addison Wesley 2001, p.258.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With