[jboss-jira] [JBoss JIRA] (WFLY-4769) WildFly 8 and 9. Connecting to topic using http-remoting and JNDI fails when server is behind NAT firewall
George Turner (JIRA)
issues at jboss.org
Mon Jan 11 14:28:00 EST 2016
[ https://issues.jboss.org/browse/WFLY-4769?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13147160#comment-13147160 ]
George Turner commented on WFLY-4769:
-------------------------------------
Is this code "compatible" with WildFly 10 and the Artemis JMS now?
Do you have an updated example. Our workaround was actually on the client side, but I would prefer this style if doable.
Sorry the CutAndPaste did not hold formatting.
public static void fixConnectionFactory(final ConnectionFactory cf, final String host) { try { Method m = findMethodByName(cf.getClass(), "getServerLocator"); if (m != null) { Object serverLocator = m.invoke(cf); Method getTransportConfigs = findMethodByName(serverLocator.getClass(), "getStaticTransportConfigurations"); if (getTransportConfigs != null) { Object transportConfigs = getTransportConfigs.invoke(serverLocator); Object firstConfig = Array.get(transportConfigs, 0); Method getParams = findMethodByName(firstConfig.getClass(), "getParams"); if (getParams != null) { Object params = getParams.invoke(firstConfig); Method put = findMethodByName(params.getClass(), "put", "String", "String"); if (put != null) { put.invoke(params, "host", host); } } } } } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { // Really shouldn't ever happen e.printStackTrace(); } } private static Method findMethodByName(Class<?> class1, String name, String... argTypeNames) { for (Method m : class1.getMethods()) { if (m.getName().equals(name) && m.getParameterTypes().length == argTypeNames.length) { return m; } } return null; }
> WildFly 8 and 9. Connecting to topic using http-remoting and JNDI fails when server is behind NAT firewall
> -----------------------------------------------------------------------------------------------------------
>
> Key: WFLY-4769
> URL: https://issues.jboss.org/browse/WFLY-4769
> Project: WildFly
> Issue Type: Bug
> Components: JMS
> Affects Versions: 8.2.0.Final, 9.0.0.CR1
> Environment: RedHat7
> Reporter: George Turner
> Assignee: Jeff Mesnil
>
> Server is behind NAT firewall. Client code:
> Properties topicProperties = new Properties();
> topicProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
> topicProperties.put(Context.PROVIDER_URL, "http-remoting://" + host + ":" + port);
> InitialContext ctx = new InitialContext(topicProperties);
> ConnectionFactory tmp = (ConnectionFactory) topicCtx.lookup("jms/RemoteConnectionFactory");
> connection = tmp.createConnection();
> Jun 11, 2015 8:26:07 AM org.xnio.Xnio <clinit>
> INFO: XNIO version 3.3.1.Final
> Jun 11, 2015 8:26:07 AM org.xnio.nio.NioXnio <clinit>
> INFO: XNIO NIO Implementation Version 3.3.1.Final
> Jun 11, 2015 8:26:07 AM org.jboss.remoting3.EndpointImpl <clinit>
> INFO: JBoss Remoting version 4.0.9.Final
> javax.jms.JMSException: Failed to create session factory
> at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:673)
> at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:112)
> at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:107)
> at com.lmco.spacefence.netcentric.test.client.TestMessageConsumer.<init>(TestMessageConsumer.java:36)
> at com.lmco.spacefence.netcentric.test.client.TestMessageConsumer.main(TestMessageConsumer.java:24)
> Caused by: HornetQNotConnectedException[errorType=NOT_CONNECTED message=HQ119007: Cannot connect to server(s). Tried with all available servers.]
> at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:905)
> at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:669)
> ... 4 more
> Disconnected from the target VM, address: '127.0.0.1:54275', transport: 'socket'
>
> Client debugger shows the ConnectionFactory instance returned:
> initialConnectors = {org.hornetq.api.core.TransportConfiguration[1]@2183}
> 0 = {org.hornetq.api.core.TransportConfiguration at 2196} "TransportConfiguration(name=http-connector, factory=org-hornetq-core-remoting-impl-netty-NettyConnectorFactory) ?port=8080&host=10-10-20-77&http-upgrade-enabled=true&http-upgrade-endpoint=http-acceptor"
> name = {java.lang.String at 2198} "http-connector"
> factoryClassName = {java.lang.String at 2199} "org.hornetq.core.remoting.impl.netty.NettyConnectorFactory"
> params = {java.util.HashMap at 2200} size = 4
> 0 = {java.util.HashMap$Node at 2203} "port" -> "8080"
> 1 = {java.util.HashMap$Node at 2204} "host" -> "10.10.20.77"
> 2 = {java.util.HashMap$Node at 2205} "http-upgrade-enabled" -> "true"
> 3 = {java.util.HashMap$Node at 2206} "http-upgrade-endpoint" -> "http-acceptor"
> 10.10.20.77 is IP address of server behind firewall, NOT the IP address used by the client.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
More information about the jboss-jira
mailing list