UnknownHostException when connecting to remote topic on jboss 7.2.0.Final
mybrandnewusername Nov 22, 2013 9:46 AMI'm trying to connect to topic on jboss 7.2.0.Final which is running on remote computer (connection works localy).
Client code:
//JNDI props Properties params = new Properties(); params.setProperty( "jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false"); params.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); params.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory"); params.setProperty(Context.PROVIDER_URL, "remote://192.168.10.222:4447"); params.setProperty(Context.SECURITY_PRINCIPAL, "user"); params.setProperty(Context.SECURITY_CREDENTIALS, "password"); //JNDI lookup and connect Context context = new InitialContext(params); ConnectionFactory cf = (ConnectionFactory) context.lookup("jms/RemoteConnectionFactory"); Destination destination = (Destination) context.lookup("jms/cms/topic/ttt"); Connection connection = cf.createConnection(user, password); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); connection.start(); //Send message MessageConsumer subscriber = session.createConsumer(destination); MessageProducer publisher = session.createProducer(destination); TextMessage message = session.createTextMessage("Hello world message."); publisher.send(message); subscriber.setMessageListener(new MessageListener() { public void onMessage(Message msg) { TextMessage tm = (TextMessage) msg; try { String message = tm.getText(); System.out.println("Got message: " + message); } catch (Exception e) { e.printStackTrace(); } } });
standalone-full.xml contains:
<jms-topic name="ttt">
<entry name="topic/ttt"/>
<entry name="java:jboss/exported/jms/cms/topic/ttt"/>
</jms-topic>
server is started like this:
./bin/standalone.sh -b 192.168.10.222 -c standalone-full.xml
All this gives me exception:
ERROR: HQ214045: Failed to create netty connection java.net.UnknownHostException: localhost.localdomain at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:579) at org.jboss.netty.channel.socket.oio.OioClientSocketPipelineSink.connect(OioClientSocketPipelineSink.java:105) at org.jboss.netty.channel.socket.oio.OioClientSocketPipelineSink.eventSunk(OioClientSocketPipelineSink.java:65) at org.jboss.netty.channel.Channels.connect(Channels.java:634) at org.jboss.netty.channel.AbstractChannel.connect(AbstractChannel.java:207) at org.jboss.netty.bootstrap.ClientBootstrap.connect(ClientBootstrap.java:229) at org.jboss.netty.bootstrap.ClientBootstrap.connect(ClientBootstrap.java:182) at org.hornetq.core.remoting.impl.netty.NettyConnector.createConnection(NettyConnector.java:505) at org.hornetq.core.client.impl.ClientSessionFactoryImpl.getConnection(ClientSessionFactoryImpl.java:1225) at org.hornetq.core.client.impl.ClientSessionFactoryImpl.getConnectionWithRetry(ClientSessionFactoryImpl.java:1071) at org.hornetq.core.client.impl.ClientSessionFactoryImpl.connect(ClientSessionFactoryImpl.java:246) at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:826) at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:583) at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:107) at ru.cniieisu.test.message.TestJMS.setup(TestJMS.java:187) at ru.cniieisu.test.message.TestJMS.testViaDirect(TestJMS.java:99) at ru.cniieisu.test.message.TestJMS$1.run(TestJMS.java:84) at ru.cniieisu.test.message.TestJMS$1.run(TestJMS.java:79) at ru.cniieisu.zkipo.szi.impl.SZIAbstract$3.run(SZIAbstract.java:506) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:415) at ru.cniieisu.zkipo.szi.impl.SZIContextAbstract.doAs(SZIContextAbstract.java:54) at ru.cniieisu.zkipo.szi.impl.SZIAbstract.activateContext(SZIAbstract.java:503) at ru.cniieisu.test.message.TestJMS.testJMS(TestJMS.java:79) at ru.cniieisu.test.message.TestJMS.main(TestJMS.java:74) javax.jms.JMSException: Failed to create session factory at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:587) at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:107) at ru.cniieisu.test.message.TestJMS.setup(TestJMS.java:187) at ru.cniieisu.test.message.TestJMS.testViaDirect(TestJMS.java:99) at ru.cniieisu.test.message.TestJMS$1.run(TestJMS.java:84) at ru.cniieisu.test.message.TestJMS$1.run(TestJMS.java:79) at ru.cniieisu.zkipo.szi.impl.SZIAbstract$3.run(SZIAbstract.java:506) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:415) at ru.cniieisu.zkipo.szi.impl.SZIContextAbstract.doAs(SZIContextAbstract.java:54) at ru.cniieisu.zkipo.szi.impl.SZIAbstract.activateContext(SZIAbstract.java:503) at ru.cniieisu.test.message.TestJMS.testJMS(TestJMS.java:79) at ru.cniieisu.test.message.TestJMS.main(TestJMS.java:74) Caused by: HornetQException[errorType=NOT_CONNECTED message=HQ119026: Cannot connect to server(s). Tried with all available servers.] at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:850) at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:583) ... 12 more
IMHO, netty is trying to connect using resolved hostname, not ip. I think, that such behavior is incorrect.
Also, I saw bug [AS7-4594] do not resolve socket-bindings used by messaging - JBoss Issue Tracker - but it seems resolved.