【问题标题】:Netty - Ignore failed setting of IP_TOSNetty - 忽略 IP_TOS 的失败设置
【发布时间】:2013-02-09 22:11:40
【问题描述】:

我的用户向我报告了这个错误,我想默默地忽略它,因为它不是我的应用程序的关键部分。

2013-02-09 15:20:15 [警告] 无法设置频道选项:[id: 0x8cf59443, /84.100.204.150:51292 => /87.98.181.225:22091] io.netty.channel.ChannelException:java.net.SocketException:无效参数:没有更多信息 在 io.netty.channel.socket.DefaultSocketChannelConfig.setTrafficClass(DefaultSocketChannelConfig.java:264) 在 io.netty.channel.socket.DefaultSocketChannelConfig.setOption(DefaultSocketChannelConfig.java:115) 在 io.netty.bootstrap.ServerBootstrap$ServerBootstrapAcceptor.inboundBufferUpdated(ServerBootstrap.java:264) 在 io.netty.channel.DefaultChannelHandlerContext.invokeInboundBufferUpdated(DefaultChannelHandlerContext.java:1170) 在 io.netty.channel.DefaultChannelHandlerContext.fireInboundBufferUpdated0(DefaultChannelHandlerContext.java:1148) 在 io.netty.channel.DefaultChannelHandlerContext.fireInboundBufferUpdated(DefaultChannelHandlerContext.java:1127) 在 io.netty.channel.DefaultChannelPipeline.fireInboundBufferUpdated(DefaultChannelPipeline.java:903) 在 io.netty.channel.socket.nio.AbstractNioMessageChannel$NioMessageUnsafe.read(AbstractNioMessageChannel.java:84) 在 io.netty.channel.socket.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:397) 在 io.netty.channel.socket.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:361) 在 io.netty.channel.socket.nio.NioEventLoop.run(NioEventLoop.java:301) 在 io.netty.channel.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:110) 在 java.lang.Thread.run(未知来源) 原因:java.net.SocketException:无效参数:没有更多信息 在 sun.nio.ch.Net.setIntOption0(本机方法) 在 sun.nio.ch.Net.setSocketOption(未知来源) 在 sun.nio.ch.SocketChannelImpl.setOption(未知来源) 在 sun.nio.ch.SocketAdaptor.setIntOption(未知来源) 在 sun.nio.ch.SocketAdaptor.setTrafficClass(未知来源) 在 io.netty.channel.socket.DefaultSocketChannelConfig.setTrafficClass(DefaultSocketChannelConfig.java:262) ... 12 更多

为此,我只需在ServerBootstrap 中设置IP_TOS 选项: childOption(ChannelOption.IP_TOS, 0x18)

如果您知道我需要在哪里放置处理程序,或者选择忽略设置此选项失败的选项,请告诉我。

md_5

【问题讨论】:

    标签: java netty


    【解决方案1】:

    这是一个设置选项的示例引导代码:

            Bootstrap b = new Bootstrap();
            b.group(new NioEventLoopGroup(), new NioEventLoopGroup())
             .channel(NioServerSocketChannel.class)
             .option(ChannelOption.SO_BACKLOG, 100)
             .handler(new LoggingHandler(LogLevel.INFO))
             .childHandler(new ChannelInitializer<SocketChannel>() {
                 @Override
                 public void initChannel(SocketChannel ch) throws Exception {
                     try {
                         ch.config().setTrafficClass(0x18);
                     } catch (ChannelException e) {
                         // Ignore
                     }
                     ch.pipeline().addLast(
                             new LoggingHandler(LogLevel.INFO),
                             new EchoServerHandler());
                 }
             });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-09-02
      • 2021-10-28
      • 2013-07-06
      • 2015-04-27
      • 2012-01-15
      • 2012-06-17
      • 2020-02-29
      相关资源
      最近更新 更多