Ganesh Pethkar
Ganesh Pethkar

Reputation: 21

Receiving error - "org.apache.http.ConnectionClosedException: Premature end of chunk coded message body: closing chunk expected" inJMeter

I am using JMeter 5.4.1, where I am using a HTTP request for Post API call. I am getting the error - "org.apache.http.ConnectionClosedException: Premature end of chunk coded message body: closing chunk expected".

Keep-Alive is checked. Timeouts are also set to 60 Seconds.

I am getting this error after almost 30-45 Minutes when thread is started. I am using single thread.

What is the solution to get raid of this?

org.apache.http.ConnectionClosedException: Premature end of chunk coded message body: closing chunk expected
at org.apache.http.impl.io.ChunkedInputStream.getChunkSize(ChunkedInputStream.java:263)
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:1936)
at org.apache.jmeter.protocol.http.sampler.HTTPAbstractImpl.readResponse(HTTPAbstractImpl.java:476)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:673)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:66)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1296)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1285)
at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:638)
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(Unknown Source)

Upvotes: 1

Views: 8807

Answers (2)

Vijay Hugar
Vijay Hugar

Reputation: 51

Adding Content-Type as application/json under Header solved my problem. Please see the below image

Header Setting

Upvotes: 0

Dmitri T
Dmitri T

Reputation: 168002

The error indicates that your server uses chunked Transfer-Encoding and doesn't provide last-chunk

Most probably you're getting an incomplete response therefore JMeter reports this error.

My expectation is that your server gets overloaded therefore it cannot properly respond to JMeter's requests so there is nothing you "get raid" of from JMeter perspective, the issue needs to be fixed on the server side.

  1. Check your server logs

  2. Make sure that the server has enough headroom to operate in terms of CPU, RAM, etc., it can be done using JMeter PerfMon Plugin

  3. Enable debug logging for JMeter's HTTP components by adding the next line to log4j2.xml file:

    <Logger name="org.apache.http" level="debug" />
    

    this way you will be able to see full request/response details in the jmeter.log file and it should allow you to get to the bottom of the issue.

Upvotes: 0

Related Questions