Wildfly:AMQ214016:无法从 natted 网络上的客户端创建 netty 连接离子 java.nio.channels.UnresolvedAddressException

Wildfly: AMQ214016: Failed to create netty connect ion java.nio.channels.UnresolvedAddressException from client on natted network

我在 docker 容器 (Container-A) 中安装了一个 wildfly 10 实例。如果我尝试从同一引擎(Server-B,引擎)的其他容器中查找队列,一切正常。

我有问题(请参阅下面的跟踪),相反,当我尝试使用服务器 B 在端口 7080 上的 IP 地址从引擎(服务器 C)的同一网络上的虚拟机查找队列时映射到容器的8080端口。

我尝试打开从 Server-C 到 Container-A 的 telnet 连接(使用 Server-B 的 IP 地址和 7080 端口),连接看起来正常。

谁能帮帮我??

C:\App>java -jar my-jar.jar
log4j:WARN No appenders could be found for logger (com.myApp.S
etUpBowcaster).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more in
fo.
2017-05-30 18:44:01 INFO  SetUpBowcaster:? - PROCESSORS BUSES INITIALIZATION
2017-05-30 18:44:01 INFO  xnio:93 - XNIO version 3.3.4.Final
2017-05-30 18:44:01 INFO  nio:55 - XNIO NIO Implementation Version 3.3.4.Final
2017-05-30 18:44:01 INFO  remoting:73 - JBoss Remoting version 4.0.18.Final
2017-05-30 18:44:01 INFO  remoting:103 - EJBCLIENT000017: Received server versio
n 2 and marshalling strategies [river]
2017-05-30 18:44:01 INFO  remoting:219 - EJBCLIENT000013: Successful version han
dshake completed for receiver context EJBReceiverContext{clientContext=org.jboss
.ejb.client.EJBClientContext@15b3e5b, receiver=Remoting connection EJB receiver
[connection=Remoting connection <56467971>,channel=jboss.ejb,nodename=my-jms-master]} on channel Channel ID b9880cf2 (outbound) of Remoting connec
tion 71d15f18 to /10.0.0.247:7080
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further detail
s.
2017-05-30 18:44:02 INFO  client:45 - JBoss EJB Client version 2.1.4.Final
2017-05-30 18:44:03 ERROR client:686 - AMQ214016: Failed to create netty connect
ion
java.nio.channels.UnresolvedAddressException
        at sun.nio.ch.Net.checkAddress(Net.java:123)
        at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:622)
        at io.netty.channel.socket.nio.NioSocketChannel.doConnect(NioSocketChann
el.java:209)
        at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.connect(Abs
tractNioChannel.java:207)
        at io.netty.channel.DefaultChannelPipeline$HeadContext.connect(DefaultCh
annelPipeline.java:1097)
        at io.netty.channel.AbstractChannelHandlerContext.invokeConnect(Abstract
ChannelHandlerContext.java:471)
        at io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChanne
lHandlerContext.java:456)
        at io.netty.channel.ChannelOutboundHandlerAdapter.connect(ChannelOutboun
dHandlerAdapter.java:47)
        at io.netty.channel.CombinedChannelDuplexHandler.connect(CombinedChannel
DuplexHandler.java:167)
        at io.netty.channel.AbstractChannelHandlerContext.invokeConnect(Abstract
ChannelHandlerContext.java:471)
        at io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChanne
lHandlerContext.java:456)
        at io.netty.channel.ChannelDuplexHandler.connect(ChannelDuplexHandler.ja
va:50)
        at io.netty.channel.AbstractChannelHandlerContext.invokeConnect(Abstract
ChannelHandlerContext.java:471)
        at io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChanne
lHandlerContext.java:456)
        at io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChanne
lHandlerContext.java:438)
        at io.netty.channel.DefaultChannelPipeline.connect(DefaultChannelPipelin
e.java:908)
        at io.netty.channel.AbstractChannel.connect(AbstractChannel.java:203)
        at io.netty.bootstrap.Bootstrap.run(Bootstrap.java:166)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(Single
ThreadEventExecutor.java:358)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)
        at io.netty.util.concurrent.SingleThreadEventExecutor.run(SingleThread
EventExecutor.java:112)
        at java.lang.Thread.run(Thread.java:745)
Exception in thread "main" com.myApp.exceptions.ProcessorStart
upException: javax.jms.JMSException: Failed to create session factory
        at com.myApp.SetUpBowcaster.main(Unknown Source)
Caused by: javax.jms.JMSException: Failed to create session factory
        at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.crea
teConnectionInternal(ActiveMQConnectionFactory.java:727)
        at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.crea
teQueueConnection(ActiveMQConnectionFactory.java:284)
        at com.myApp.applicationLayer.jms.BowcasterProcessorsH
andlersManager.setUpJmsConnection(Unknown Source)
        at com.myApp.applicationLayer.jms.BowcasterProcessorsH
andlersManager.<init>(Unknown Source)
        at com.myApp.applicationLayer.jms.BowcasterProcessorsH
andlersManager.getInstance(Unknown Source)
        ... 1 more
Caused by: ActiveMQNotConnectedException[errorType=NOT_CONNECTED message=AMQ1190
07: Cannot connect to server(s). Tried with all available servers.]
        at org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.create
SessionFactory(ServerLocatorImpl.java:777)
        at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.crea
teConnectionInternal(ActiveMQConnectionFactory.java:724)
        ... 5 more
2017-05-30 18:44:03 INFO  remoting:482 - EJBCLIENT000016: Channel Channel ID b98
80cf2 (outbound) of Remoting connection 71d15f18 to /10.0.0.247:7080 can no long
er process messages

address:port 可能需要完全限定。我通过更改代码中的以下 属性 来修复此问题:

artemis.nodes=machine-artemis-01:port

至:

artemis.nodes=machine-artemis-01.place.company.com:port

我通过这种方式创建连接解决了:

Map<String, Object> connectionParams = new HashMap<String, Object>();
connectionParams.put(org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.HOST_PROP_NAME, nattedIp); // <-- PUT THE NATTED IP HERE!
connectionParams.put(org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.PORT_PROP_NAME, nattedPort);
connectionParams.put(org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.HTTP_UPGRADE_ENABLED_PROP_NAME, "true");
connectionParams.put(org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.HTTP_UPGRADE_ENDPOINT_PROP_NAME, "http-acceptor");

TransportConfiguration transportConfiguration = new org.apache.activemq.artemis.api.core.TransportConfiguration(JMS_NETTY_CONNECTOR_FACTORY_PROPERTY_NAME, connectionParams);

ActiveMQConnectionFactory jmsConnnectionFactory =     ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.TOPIC_CF, transportConfiguration);

if (jmsConnnectionFactory != null) {    
    jmsConnnection = jmsConnnectionFactory.createConnection();
}