【问题标题】:Netty Decoding failed DefaultFullHttpRequestNetty 解码失败 DefaultFullHttpRequest
【发布时间】:2022-07-15 17:56:54
【问题描述】:

我目前正在使用 spring boot webflux 进行开发。我正在使用 websocket 客户端和 API 客户端,但在部署后几个小时会出现此错误。我无法弄清楚这个错误来自哪里。这个问题是从哪里来的?

错误日志如下。

[reactor-http-epoll-2] r.n.http.server.HttpServerOperations     : [9c0c3ede, L:/172.25.0.8:8080 - R:/94.232.43.63:34534] Decoding failed: DefaultFullHttpRequest(decodeResult: failure(java.lang.IllegalArgumentException: text is empty (possibly HTTP/0.9)), version: HTTP/1.0, content: UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeHeapByteBuf(ridx: 0, widx: 0, cap: 0))
GET /bad-request HTTP/1.0 :

java.lang.IllegalArgumentException: text is empty (possibly HTTP/0.9)
        at io.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:65) ~[netty-codec-http-4.1.72.Final.jar:4.1.72.Final]
        at io.netty.handler.codec.http.HttpRequestDecoder.createMessage(HttpRequestDecoder.java:126) ~[netty-codec-http-4.1.72.Final.jar:4.1.72.Final]
        at io.netty.handler.codec.http.HttpObjectDecoder.decode(HttpObjectDecoder.java:273) ~[netty-codec-http-4.1.72.Final.jar:4.1.72.Final]
        at io.netty.handler.codec.http.HttpServerCodec$HttpServerRequestDecoder.decode(HttpServerCodec.java:140) ~[netty-codec-http-4.1.72.Final.jar:4.1.72.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:507) ~[netty-codec-4.1.72.Final.jar:4.1.72.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:446) ~[netty-codec-4.1.72.Final.jar:4.1.72.Final]

有时还会在句子“文本为空”中发现损坏的字符。 如果这是编码问题,我应该如何设置?

【问题讨论】:

  • 您有解决这个问题的办法吗?我面临同样的问题,它在解码时失败。

标签: java spring spring-boot netty webflux


【解决方案1】:

您可能仅在 http 上运行 spring boot 应用程序,然后通过 https 访问它(或者您的浏览器正在重定向到 https),因此未正确解析 http 版本。您还应该:

java.lang.IllegalArgumentException: invalid version format: S���JZ
        at io.netty.handler.codec.http.HttpVersion.<init>(HttpVersion.java:116) ~[netty-codec-http-4.1.73.Final.jar!/:4.1.73.Final]

请确保正确的浏览器/请求/协议/编码。

【讨论】:

    【解决方案2】:

    在将所有标头从一个微服务委托给另一个微服务时发现问题。现在已经删除了这个,我正在选择特定的标题以进一步委派。

    【讨论】:

      猜你喜欢
      • 2023-03-30
      • 2013-09-27
      • 2020-01-18
      • 1970-01-01
      • 2014-02-08
      • 2018-07-25
      • 1970-01-01
      • 2018-03-02
      相关资源
      最近更新 更多