SpringCloudGateway报打开的文件过多的问题

一 问题描述:

环境版本:

# Spring Boot版本
springBootVersion=2.3.1.RELEASE
# Spring Cloud版本
springCloudVersion=Hoxton.SR6

SpringCloudGateway网关运行一段时间之后,服务无端端挂掉了,但是jps查进程是还在的,然后通过查看日志发现了不断在报一个WARN如下:

io.netty.channel.unix.Errors$NativeIoException: accept(..) failed: 打开的文件过多

2020-10-12 09:49:33.132  WARN 25838 --- [or-http-epoll-1] io.netty.channel.DefaultChannelPipeline  : An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.

# 或者英文错误:
io.netty.channel.unix.Errors$NativeIoException: accept(..) failed: Too many open files

二 问题原因:

通过查看github上spring-cloud-gateway issue找到了对应的问题的原因,并且级联找到对应的问题根源所在的reactor-netty和spring-boot上报出来的issues如下:

https://github.com/reactor/reactor-netty/issues/1152

https://github.com/spring-projects/spring-boot/issues/21923

真正的原因是:reactor-natty:0.9.8.RELEASE 存在描述符泄漏问题

我们查看一下依赖

+--- org.springframework.cloud:spring-cloud-starter-gateway -> 2.2.3.RELEASE
|    \--- org.springframework.boot:spring-boot-starter-webflux:2.3.0.RELEASE -> 2.3.1.RELEASE
|         +--- org.springframework.boot:spring-boot-starter-reactor-netty:2.3.1.RELEASE
|         |    \--- io.projectreactor.netty:reactor-netty -> 0.9.8.RELEASE

依赖中reactor-netty的版本确实是:0.9.8.RELEASE(有bug的版本)

三 解决办法:

方法一:升级SpringBoot版本到2.3.4.RELEASE,顺便把SpringCloud的版本升级到Hoxton.SR8

解决之后的依赖如下:

+--- org.springframework.cloud:spring-cloud-starter-gateway -> 2.2.5.RELEASE
|    \--- org.springframework.boot:spring-boot-starter-webflux:2.3.2.RELEASE -> 2.3.4.RELEASE
|         +--- org.springframework.boot:spring-boot-starter-reactor-netty:2.3.4.RELEASE
|         |    \--- io.projectreactor.netty:reactor-netty:0.9.12.RELEASE

方法二:在org.springframework.cloud:spring-cloud-starter-gateway依赖中exclude掉io.projectreactor.netty:reactor-netty:0.9.8.RELEASE,并且额外引入io.projectreactor.netty:reactor-netty:0.9.12.RELEASE依赖。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值