org.springframework.web.reactive.function.client.WebClient MalformedChunkCodingException:坏块头

问题描述

我有一个Spring Boot应用程序(2.2.6.RELEASE),该应用程序通过以下方式调用其他Spring Boot服务 org.springframework.web.reactive.function.client.WebClient通过以下方式构建:

final SslContext sslContext = buildSslContext(keyStorePassword,trustStore,keyStore);

final HttpClient httpClient = HttpClient.create().secure(ssl -> ssl.sslContext(sslContext));

return WebClient.builder().clientConnector(new ReactorClientHttpConnector(httpClient.wiretap(true)))
                .exchangeStrategies(loggingExchangeStrategy()).build();

通常这可以正常工作。但是,当我开始使用jmeter对应用程序进行性能测试并用请求轰炸它时,我随机开始收到失败的响应,但有以下异常:

org.apache.http.MalformedChunkCodingException: Bad chunk header: {"order":{"status" {"status":"Success"}}}
    at org.apache.http.impl.io.ChunkedInputStream.getChunkSize(ChunkedInputStream.java:274)
    at org.apache.http.impl.io.ChunkedInputStream.nextChunk(ChunkedInputStream.java:222)
    at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:183)
    at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:135)
    at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:148)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.readResponse(HTTPSamplerBase.java:1905)
    at org.apache.jmeter.protocol.http.sampler.HTTPAbstractImpl.readResponse(HTTPAbstractImpl.java:476)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:668)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:66)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1281)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1270)
    at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:630)
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:558)
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
    at java.lang.Thread.run(Thread.java:748)

然后在正常测试应用程序时也遇到了类似的异常,但有以下异常:

"org.apache.http.ConnectionClosedException: Premature end of chunk coded message body: closing chunk expected\r\n\tat org.apache.http.impl.io.ChunkedInputStream.getChunkSize(ChunkedInputStream.java:268)\r\n\tat org.apache.http.impl.io.ChunkedInputStream.nextChunk(ChunkedInputStream.java:227)\r\n\tat org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:186)\r\n\tat org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:137)\r\n\tat sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)\r\n\tat sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)\r\n\tat sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)\r\n\tat 

由于异常似乎不是来自我的代码,因此问题似乎出在WebClient上。是吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)