Netty socket.io 启用Epoll 模式异常

时间:2023-03-09 21:46:30
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") > -) {
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.</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.</version>
</dependency> <dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1..Final</version>
</dependency>

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

Netty socket.io 启用Epoll 模式异常

处理方式

参考地址: https://github.com/robymus/netty-socketio/commit/fcc7d33df843eb2720529540ac1c37ffa0e262a4Netty socket.io 启用Epoll 模式异常

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