[jboss-remoting-issues] [JBoss JIRA] (JBREM-1302) Can't invoke remote object if server bind address is 0.0.0.0
Sergey Chernov (Commented) (JIRA)
jira-events at lists.jboss.org
Tue Oct 11 04:06:16 EDT 2011
[ https://issues.jboss.org/browse/JBREM-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12633727#comment-12633727 ]
Sergey Chernov commented on JBREM-1302:
---------------------------------------
Another place to look - InvokerLocator.fixRemoteAddress and InvokerLocator.resolveHost
In older version (1.4.3) '0.0.0.0' is converted to server's host name or ip:
private static String fixRemoteAddress(String address)
{
try
{
if(address == null || ANY.equals(address)) // ANY.equals(address) is removed from later version
{
boolean byHost = true;
String bindByHost = System.getProperty(BIND_BY_HOST, "True");
try
{
byHost = Boolean.getBoolean(bindByHost);
}
catch(Exception e)
{
}
if(byHost)
{
return InetAddress.getLocalHost().getHostName();
}
else
{
return InetAddress.getLocalHost().getHostAddress();
}
}
}
catch(UnknownHostException ignored)
{
}
return address;
}
Now it happens only if no address is passed in locatorURI:
private static String fixRemoteAddress(String address)
{
if(address == null)
{
try
{
> Can't invoke remote object if server bind address is 0.0.0.0
> ------------------------------------------------------------
>
> Key: JBREM-1302
> URL: https://issues.jboss.org/browse/JBREM-1302
> Project: JBoss Remoting
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: transport
> Affects Versions: 2.5.4.SP2
> Environment: Jboss 5.1.0 jdk 1.6 jboss remoting 2.5.4.SP2
> Reporter: Sergey Chernov
>
> When jboss bind address is set to `0.0.0.0` remote client gets exception while trying to invoke remote object's method:
> java.rmi.ConnectException: Connection refused to host: lx4-schernov.nn.five9.com; nested exception is:
> java.net.ConnectException: Connection refused: connect
> 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.invoke(UnicastRef.java:110)
> at org.jboss.remoting.transport.rmi.RMIServerInvoker_Stub.transport(Unknown Source)
> at org.jboss.remoting.transport.rmi.RMIClientInvoker.callTransport(RMIClientInvoker.java:648)
> at org.jboss.remoting.transport.rmi.RMIClientInvoker.access$100(RMIClientInvoker.java:78)
> at org.jboss.remoting.transport.rmi.RMIClientInvoker$1.run(RMIClientInvoker.java:402)
> at org.jboss.util.threadpool.RunnableTaskWrapper.run(RunnableTaskWrapper.java:147)
> at org.jboss.util.threadpool.BasicThreadPool.executeOnThread(BasicThreadPool.java:473)
> at org.jboss.util.threadpool.BasicThreadPool.runTaskWrapper(BasicThreadPool.java:201)
> at org.jboss.remoting.transport.rmi.RMIClientInvoker.transport(RMIClientInvoker.java:420)
> at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:169)
> at org.jboss.remoting.Client.invoke(Client.java:2070)
> at org.jboss.remoting.Client.invoke(Client.java:879)
> at org.jboss.remoting.Client.invoke(Client.java:867)
> at org.jboss.remoting.transporter.TransporterClient.invoke(TransporterClient.java:479)
> at $Proxy0.getMySumHost(Unknown Source)
> at test.Main.main(Main.java:45)
> Caused by: java.net.ConnectException: Connection refused: connect
> 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 javax.net.DefaultSocketFactory.createSocket(SocketFactory.java:206)
> at org.jboss.remoting.transport.rmi.RemotingRMIClientSocketFactory.createSocketPrivate(RemotingRMIClientSocketFactory.java:333)
> at org.jboss.remoting.transport.rmi.RemotingRMIClientSocketFactory.createSocket(RemotingRMIClientSocketFactory.java:210)
> at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
> ... 18 more
> It happens because RemotingRMIClientSocketFactory had been created with wrong ('0.0.0.0') host name which becomes effective host while creating socket:
> log:
> 328 [main] TRACE org.jboss.remoting.transport.rmi.RemotingRMIClientSocketFactory - host: lx4-schernov.nn.five9.com, effective host: 0.0.0.0, port: 47952
> source:
> public Socket createSocket(String host, final int port) throws IOException
> 176 {
> ...
> 181 final String effectiveHost = hostName != null ? hostName : host;
> While creating factory it should be checked, that host name is not broadcast or localhost address, to make client's locatorUri mandatory for such cases.
> Client source code:
> String address = "remote.host.com";
> Properties props = new Properties();
> props.put(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
> props.put(InitialContext.PROVIDER_URL, "jnp://" + address + ":1099");
> props.put(InitialContext.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
> InitialContext context = new InitialContext(props);
> Object tmp = context.lookup("remote/subsystem/Object");
> ObjectInf object = (ObjectInf) tmp;
>
> object.doJob(); // here exception it thrown
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-remoting-issues
mailing list