zoukankan      html  css  js  c++  java
  • Netty socket.io 启用Epoll 模式异常

    Epoll 环境为Linux 内核2.6 以上版本  Windows下不能启动

    1:判断Linux环境

      public static boolean isOSLinux() {
            Properties prop = System.getProperties();
            String os = prop.getProperty("os.name");
            System.out.println(os);
            if (os != null && os.toLowerCase().indexOf("linux") > -1) {
                return true;
            } else {
                return false;
            }
        }

      
      if(isOSLinux()){
      //使用Linux Epoll模型
      log.info("启用Epoll");
      config.setUseLinuxNativeEpoll(true);
      }
     

    2:pom.xml配置

    参考地址: https://www.jianshu.com/p/bb3718226f36

    <dependency>
                <groupId>com.corundumstudio.socketio</groupId>
                <artifactId>netty-socketio</artifactId>
                <version>1.7.13</version>
                <exclusions>
                    <exclusion>
                        <groupId>io.netty</groupId>
                        <artifactId>netty-common</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>io.netty</groupId>
                        <artifactId>netty-transpor</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>io.netty</groupId>
                        <artifactId>netty-buffer</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>io.netty</groupId>
                        <artifactId>netty-handler</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>io.netty</groupId>
                        <artifactId>netty-codec-http</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>io.netty</groupId>
                        <artifactId>netty-codec</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>io.netty</groupId>
                        <artifactId>netty-resolver</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>io.netty</groupId>
                        <artifactId>netty-transport</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>io.netty</groupId>
                        <artifactId>netty-transport-native-epoll</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
    
            <!-- 客户端 -->
            <dependency>
                <groupId>io.socket</groupId>
                <artifactId>socket.io-client</artifactId>
                <version>1.0.0</version>
            </dependency>
    
            <dependency>
                <groupId>io.netty</groupId>
                <artifactId>netty-all</artifactId>
                <version>4.1.16.Final</version>
            </dependency>

    3:启动成功后如图,有一个异常警告

    处理方式

    参考地址: https://github.com/robymus/netty-socketio/commit/fcc7d33df843eb2720529540ac1c37ffa0e262a4

     4: SO_LINGER 什么意思呢,
    参考地址: https://www.jianshu.com/p/0bff7c020af2

  • 相关阅读:
    xxx
    04消息队列zmq的发布者-订阅者的计算π的简单程序。
    03网络编程从之异步服务器
    03Python网络编程之多线程服务端。
    03Python网络编程之单线程服务端
    03Python网络编程之客户端。
    03Python网络编程系列之服务端
    02select监听客户端
    02select监听服务端
    07爬虫之-urllib总结
  • 原文地址:https://www.cnblogs.com/eason-d/p/9707986.html
Copyright © 2011-2022 走看看