我是靠谱客的博主 玩命世界,这篇文章主要介绍[WebFlux] 由于没有处理Netty HTTP表体导致的问题场景一场景二遗留问题,现在分享给大家,希望可以做个参考。

[WebFlux] 由于没有处理Netty HTTP表体导致的问题

  • 场景一
  • 场景二
  • 遗留问题

HTTP请求有表体,但是WebFlux应用没有获取表体内容并进行处理。接下来

场景一

环境部署:Postman -> Nginx -> WebFlux Server
问题:通过Postman发送包含表体的请求时,会经常出现无返回的情形,经查Nginx端出现错误

2019/12/06 12:08:30 [error] 395614#0: *222 readv() failed (104: Connection reset by peer) while reading upstream, client: 172.20.17.75, server: gwdemo.to.com, request: “GET /game/animal/get HTTP/1.1”, upstream: “http://127.0.0.1:1601/game/animal/get”, host: “gwdemo.to.com”

通过拿掉 Nginx 或 修改nginx配置关闭缓存可解决

proxy_buffering off;

具体原因不明!

场景二

环境部署: Postman -> Nginx-1 -> Spring Cloud Gateway -> Nginx-2 -> WebFlux Server
问题:通过Postman发送包含表体请求时,返回错误信息,经查

Nginx1 错误

2019/12/06 13:57:05 [error] 418274#0: *388169 upstream prematurely closed connection while reading response header from upstream, client: 172.17.54.60, server: gw.to.com, request: “GET /demo/game/animal/get HTTP/1.1”, upstream: “http://127.0.0.1:1601/demo/game/animal/get”, host: “gw.to.com”

Spring Cloud Gateway 错误

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
2019-12-06 12:08:29.840 ERROR 417902 --- [reactor-http-epoll-48] a.w.r.e.AbstractErrorWebExceptionHandler : [6729ed7b] 500 Server Error for HTTP GET "/demo/game/animal/get" reactor.netty.http.client.PrematureCloseException: Connection prematurely closed DURING response Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: Assembly trace from producer [reactor.core.publisher.FluxMap] : reactor.core.publisher.Flux.map(Flux.java:5734) reactor.netty.ByteBufFlux.fromInbound(ByteBufFlux.java:70) Error has been observed by the following operator(s): |_ Flux.map ⇢ reactor.netty.ByteBufFlux.fromInbound(ByteBufFlux.java:70) |_ Flux.doOnNext ⇢ reactor.netty.ByteBufFlux.retain(ByteBufFlux.java:298) |_ Flux.map ⇢ org.springframework.cloud.gateway.filter.NettyWriteResponseFilter.lambda$filter$1(NettyWriteResponseFilter.java:89) |_ Mono.doOnError ⇢

遗留问题

虽然最终通过接收并处理 HTTP请求体 解决了上述问题,但具体是什么原因导致连接提前关闭至今没有找到答案,同志仍需努力啊!

最后

以上就是玩命世界最近收集整理的关于[WebFlux] 由于没有处理Netty HTTP表体导致的问题场景一场景二遗留问题的全部内容,更多相关[WebFlux]内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(68)

评论列表共有 0 条评论

立即
投稿
返回
顶部