WS.sendRequest ConnectionClosedException when handling gzip encoded rest response

I have springboot webservices (running on jboss) that return json data where content-encoding is gzip. I can hit the service via browser, using the url and it displays all the json data as expected. When I run a Kat test ustilizing WS.sendRequest, the following error is shown in the console:
org.apache.http.ConnectionClosedException: Premature end of Content-Length delimited
message body (expected: 91834; received: 13653
at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:180)
at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:200)
at org.apache.http.impl.io.ContentLengthInputStream.close(ContentLengthInputStream.java:103)
at org.apache.http.impl.execchain.ResponseEntityProxy.streamClosed(ResponseEntityProxy.java:140)
at org.apache.http.conn.EofSensorInputStream.checkClose(EofSensorInputStream.java:228)
at org.apache.http.conn.EofSensorInputStream.close(EofSensorInputStream.java:174)
at java.util.zip.InflaterInputStream.close(InflaterInputStream.java:227)
at java.util.zip.GZIPInputStream.close(GZIPInputStream.java:136)
at org.apache.http.client.entity.LazyDecompressingInputStream.close(LazyDecompressingInputStream.java:97)
at org.apache.http.util.EntityUtils.toString(EntityUtils.java …

As a side note, the services on the backend were just converted to springboot and were previously using resteasy implementation. This test ran fine with that. But the response in the browser is fine with all the proper headers, so I don’t see why Katalon is having a problem getting the data from the endpoint, no errors server side. Running studio version 8.4.1. Any ideas on things to try? The response isn’t that large as you can see from the numbers above. I’m not sure how to even debug this from the Katalon side.

See the following post:

I think that Katalon Studio does not work with WS respose with a header Content-Type: gzip.

You have options:

  1. Change your Web Service so that it stops using Content-Type: gzip and test it with KS.
  2. Keeep the Web Service as is, test it using other tools that support Content-Type: gzip appropriately.

I know that’s not entirely true. These services were successfully tested for some time using Katalon tests (aka WS.sendRequest) with Content-Encoding: gzip before they were converted to utilize the springboot framework. The tests ran fine when the services used the RestEasy framework and they were gzip then. This made me believe it was something on the server side where possibly springboot was sending different header information. Unless someone can tell me officially that Katalon does not support gzip encoded services.

Thx

Thank you for your reply. In fact, I am not very sure.

Just I think WS testing features of KS are not tested very well.

If I were you, I would read the StackTrace messages (which you trimmed short) from top to bottom and find out “Root cause” section. In the “Root cause” section, you will find out which class of com.kms.katalon.core.* & which line of the *.java file raised the Exception.

Once you identified the exact location where the Exception was raised, I will look at the source code of Katalon Studio. You can find the source at

GitHub - katalon-studio/katalon-studio-testing-framework: Katalon Studio Open-source Testing Framework

Then I would study the source of Katalon class, try to understad how it behaves. You would be able to develop a mimic of the faulty Katalon class (which drives Apache Http Client library). You would be able to test your mimic against the URL of your Application Under Test. Thus you might be able to reproduce the “ConnectionClosedException” issue. Once you could reproduce the insident, it would be 100% clear to you what was the root cause of the exception.

Good idea, you are right, the trace was truncated. If it comes to that, I may dig into Katalon souce, though I’d rather not …

Thx! Mike

1 Like

You need to spend your time to debug KS.

I am afraid, the Katalon developers seem to be un-keen on developing WS features these days. They seem to be busy developing the “Katalon Platform”. I do not think that your post concerning WS will be addressed by them. Your effort may go wasted.

It would be easier if you choose other tools for Web Service testing …