Connection prematurely closed BEFORE response reactor.netty.http.client.PrematureCloseException: Co
一、最近在开发网关系统,就在感觉万事大吉可以上线的时候发现了如下的错误(这个是我在配置rabbitmq访问多个服务时发现的)
Connection prematurely closed BEFORE response
reactor.netty.http.client.PrematureCloseException: Connection prematurely closed BEFORE response
reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):|_ checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]|_ checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]|_ checkpoint ⇢ HTTP GET "/rabbitmq/api/vhosts" [ExceptionHandlingWebHandler]
什么意思呢?就是在请求还未响应的时候连接直接断开了,什么情况,崩溃,但是问题还是要解决于是开始了度娘之路,来看下如下这张图:
由上图可知发生异常的原因是从连接池中拿到连接之后发送请求,请求还未到达目标服务器就已经被目标服务器关闭了;而SCG中的连接还未被回收掉;
二、解决方案
第一步添加JVM参数,更改从连接池中取连接的策略,由FIFO变更为LIFO(reactor.netty.resources.ConnectionProvider),确保拿到的连接永远是最新的连接;
-Dreactor.netty.pool.leasingStrategy=lifo
第二步设置连接空闲多久后会被回收掉,这个时间要比对应服务的回收时间小(tomcat对应的是server.tomcat.connection-timeout属性配置,在浏览器中看到的就是keep-Alive),这样就可以确保SCG回收连接在后端服务之前进行,完美避开这个问题;
spring:cloud:gateway:httpclient:pool:maxIdleTime: PT1S
GitHub地址:https://github.com/mingyang66/EmilyGateway/tree/main/doc
Connection prematurely closed BEFORE response reactor.netty.http.client.PrematureCloseException: Co相关推荐
- Gateway加解密偶尔HTTP method names must be tokensConnection prematurely closed BEFORE response问题
背景 在上篇博客中使用了RSA配合AES完成了接口的加解密操作,但是在实际测试过程中,偶尔会产生`HTTP method names must be tokens`.`Connection prema ...
- gateway网关调用报 reactor.netty.http.client.HttpClient.chunkedTransfer(Z)Lreactor/netty/http/client/HttpC
reactor.netty.http.client.HttpClient.chunkedTransfer(Z)Lreactor/netty/http/client/HttpClient; 这个错误是因 ...
- 【问题归纳】开启gateway网关调用报错: reactor.netty.http.client.HttpClient.chunkedTransfer(Z)L
开启 gateway 网关报错reactor.netty.http.client.HttpClient.chunkedTransfer(Z)Lreactor/netty/http/client/Htt ...
- Connection has been closed BEFORE response异常
最近我组使用的spring cloud gateway 线上偶发返回500,后台查看报错日志信息,发现有一条下面的异常: reactor.netty.channel.AbortedException: ...
- [翻译]Reactor Netty参考指南 - 8.UDP客户端
Reactor Netty参考指南目录 原文地址 Reactor Netty提供了易于使用.易于配置的UdpClient.它隐藏了创建UDP客户端所需的大部分Netty的功能,并增加了Reactive ...
- 解决 ”upstream prematurely closed connection while reading response header from upstream“ 问题,运行环境为:ngi
解决 "upstream prematurely closed connection while reading response header from upstream" 问题 ...
- 【转】The underlying connection was closed
转自: https://support.microsoft.com/en-us/kb/915599 SUMMARY This article describes error messages that ...
- [WebException: The underlying connection was closed: The message length limit was exceeded.]解决方法...
[WebException: The underlying connection was closed: The message length limit was exceeded.] System. ...
- 【Mybatis】sqlSessionTemplate.getConnection() 遇到 java.sql.SQLException: Connection is closed
这里写目录标题 前言 源码 遇到错误 `java.sql.SQLException: Connection is closed` 错误原因 解决办法 修改后的源码 前言 springboot 2.1. ...
最新文章
- 解决“SCRIPT257: 由于出现错误 80020101 而导致此项操作无法完成。 ”
- 【游戏】疯狂坦克2街机版(不需模拟器)
- 解决sharepoint 2010浏览器在线浏览Word出错
- 机器学习:结点的实现,决策树代码实现(二)
- Excel 打开csv显示在一个单元格
- leetcode 210. Course Schedule II | 210. 课程表 II(Java)
- (转)Apache与Tomcat 区别联系
- 2022年中国母婴新消费白皮书
- iOS 疑难杂症 — — 推送本地国际化 loc-key 本地化失败的问题
- 无线充qi协议c语言详解,QI无线充通信协议数据包格式解析
- Linux版awvs最新版v_190325161的安装记录
- 【啊哈C语言】【习题答案】【第一章】
- PLC跑马灯程序设计
- android仿ios下拉框,android 自定义ListView仿IOS阻尼效果
- Notification 模拟收到短信,数据下载的状态栏提示
- 宽带IPTV单线复用
- 2021-2027全球与中国GPU服务器市场现状及未来发展趋势
- Msfvenom使用指南
- canvas画布的基础用法
- vue3使用element组件中的Image导致频闪