我一直在努力让Camel Netty4 udp多播在Windows上工作,而NettyUDPMulticastAsyncTest似乎失败了java.nio.channels.ClosedChannelException。 同样的测试似乎在OSX上工作。这两台机器都运行Java 1.7 我已经更新了测试中的接口名称,并且能够在同一个接口上运行NIO UDP多播示例。 我使用的是Camel 2.14.1,但它似乎也不适用于2.15.x.
堆栈跟踪在下面。
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.026 sec <<< FAILURE! - in org.apache.camel.component.netty4.NettyUDPMulticastAsyncTest
testUDPInOnlyMulticastWithNettyConsumer(org.apache.camel.component.netty4.NettyUDPMulticastAsyncTest) Time elapsed: 0.023 sec <<< ERROR!
java.nio.channels.ClosedChannelException: null
at sun.nio.ch.DatagramChannelImpl.innerJoin(DatagramChannelImpl.java:832)
at sun.nio.ch.DatagramChannelImpl.join(DatagramChannelImpl.java:894)
at io.netty.channel.socket.nio.NioDatagramChannel.joinGroup(NioDatagramChannel.java:409)
at io.netty.channel.socket.nio.NioDatagramChannel.joinGroup(NioDatagramChannel.java:382)
at io.netty.channel.socket.nio.NioDatagramChannel.joinGroup(NioDatagramChannel.java:375)
at org.apache.camel.component.netty4.SingleUDPNettyServerBootstrapFactory.startServerBootstrap(SingleUDPNettyServerBootstrapFactory.java:177)
at org.apache.camel.component.netty4.SingleUDPNettyServerBootstrapFactory.doStart(SingleUDPNettyServerBootstrapFactory.java:97)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
at org.apache.camel.component.netty4.NettyConsumer.doStart(NettyConsumer.java:69)
答案 0 :(得分:0)
在加入组之前发现绑定到多播地址的问题,由于某种原因在Windows上不起作用。不得不在 SingleUDPNettyServerBootstrapFactory
中更新bootstrap.bind看起来像这样ChannelFuture channelFuture = bootstrap.bind(new InetSocketAddress(configuration.getPort()));