An rmi-user has requested that RMI should have the ability to dynamically update its serverHostName. It is possible for a machine's hostname/ip address to change when that host establishes network connectivity (i.e. for a dhcp served ). Currently RMI detects a machine's hostname in a static block of code when the VM starts up. There needs to be some API that will allow a user to dynamically alter a server hostname to allow RMI to fully support DHCP served hosts.
The user request follows:
Unable to find a way to tell RMI that the IP address and even the
hostname of the machine has changed. This is a serious problem on
dial-up hosts without a fixed hostname. There are dial-up servers which
dynamically deal IP-address AND hostname per connection.
Imagine the situation where remote server objects on a host with dial-up
connection are bound to a name service. While there is no dial-up
connection they are unreachable of course, but once a dial-up connection
has been established they should become reachable. So whenever a new
connection is ready, the server objects rebind themselves at the name
service - in vain if the IP-address and/or hostname are new. Why in
vain? Because RMI stubs are serialized so that they contain the
IP-address/hostname first seen by RMI.
Setting the java.rmi.server.hostname property takes effect only once and
only if done before using RMI; AND
java.net.InetAddress.getLocalHost() fails to recover new
hostname/IP-address so that setting java.rmi.server.useLocalHostName to
true doesn't help.
However there exist other means (by explicit end-user intervention for
example) to discover the new hostname and IP-address.
I think RMI should provide a way to set the hostname/IP-address to use
for serializing stubs. It looks very strange when a stub is serialized
as listening on [a:p] while it is listening really on [b:p]. An
IP-address-aware RMISocketFactory can create right sockets as
construction of a java.net.Socket/ServerSocket succeeds by specifying
the real IP-address (differing from what RMI uses for stubserialization)
as the localaddress!.
Private RMISocketFactory could solve problem if InetAddres weren't
final!
The user request follows:
Unable to find a way to tell RMI that the IP address and even the
hostname of the machine has changed. This is a serious problem on
dial-up hosts without a fixed hostname. There are dial-up servers which
dynamically deal IP-address AND hostname per connection.
Imagine the situation where remote server objects on a host with dial-up
connection are bound to a name service. While there is no dial-up
connection they are unreachable of course, but once a dial-up connection
has been established they should become reachable. So whenever a new
connection is ready, the server objects rebind themselves at the name
service - in vain if the IP-address and/or hostname are new. Why in
vain? Because RMI stubs are serialized so that they contain the
IP-address/hostname first seen by RMI.
Setting the java.rmi.server.hostname property takes effect only once and
only if done before using RMI; AND
java.net.InetAddress.getLocalHost() fails to recover new
hostname/IP-address so that setting java.rmi.server.useLocalHostName to
true doesn't help.
However there exist other means (by explicit end-user intervention for
example) to discover the new hostname and IP-address.
I think RMI should provide a way to set the hostname/IP-address to use
for serializing stubs. It looks very strange when a stub is serialized
as listening on [a:p] while it is listening really on [b:p]. An
IP-address-aware RMISocketFactory can create right sockets as
construction of a java.net.Socket/ServerSocket succeeds by specifying
the real IP-address (differing from what RMI uses for stubserialization)
as the localaddress!.
Private RMISocketFactory could solve problem if InetAddres weren't
final!