Reputation: 105
I am trying to create a server for receiving UDP messages using NioUdtMessageConnectorChannel as channel. Pasting the code for the server
EventLoopGroup group = new NioEventLoopGroup(50,
Executors.defaultThreadFactory());
try {
Bootstrap b = new Bootstrap();
b.group(group);
b.channel(NioUdtMessageConnectorChannel.class);
b.option(UdtChannelOption.SO_BROADCAST, true);
b.option(UdtChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, 1024);
b.option(UdtChannelOption.PROTOCOL_RECEIVE_BUFFER_SIZE, 1024);
b.option(UdtChannelOption.PROTOCOL_SEND_BUFFER_SIZE, 1024);
b.option(UdtChannelOption.TCP_NODELAY, true);
b.option(UdtChannelOption.SO_RCVBUF, 256 * 1024);
b.handler(new SNMPTrapHandler());
b.bind(PORT).sync().channel().closeFuture().await();
} finally {
group.shutdownGracefully();
}
However, I am getting below error
log4j:WARN Please initialize the log4j system properly.
java.nio.channels.IllegalSelectorException
at sun.nio.ch.SelectorImpl.register(Unknown Source)
at java.nio.channels.spi.AbstractSelectableChannel.register(Unknown Source)
at io.netty.channel.nio.AbstractNioChannel.doRegister(AbstractNioChannel.java:308)
at io.netty.channel.AbstractChannel$AbstractUnsafe.register0(AbstractChannel.java:439)
at io.netty.channel.AbstractChannel$AbstractUnsafe.access$100(AbstractChannel.java:374)
at io.netty.channel.AbstractChannel$AbstractUnsafe$1.run(AbstractChannel.java:418)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:353)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
at java.lang.Thread.run(Unknown Source)
What is the exact error?
Upvotes: 0
Views: 379
Reputation: 12351
You have to specify the UDT selector provider when you create an NioEventLoopGroup
. For example:
new NioEventLoopGroup(..., NioUdtProvider.MESSAGE_PROVIDER);
For more information, please refer to the UDT examples.
Upvotes: 1