Skip to content
This repository has been archived by the owner on Apr 4, 2022. It is now read-only.

Multipart post request fails randomly with error java.io.IOException: insufficient data written #215

Open
Blu-Dragon opened this issue Dec 15, 2020 · 0 comments

Comments

@Blu-Dragon
Copy link

Blu-Dragon commented Dec 15, 2020

I have an application that sends data to an API in a multipart post request. The application works properly throughout the day but it fails sometimes randomly or multiple times consecutively. The error log is as follows:

java.io.IOException: insufficient data written
at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.close(HttpURLConnection.java:3558)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1521)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:347)
at scalaj.http.HttpRequest.scalaj$http$HttpRequest$$doConnection(Http.scala:367)
at scalaj.http.HttpRequest.exec(Http.scala:343)
at scalaj.http.HttpRequest.asString(Http.scala:491)

That occurs at the line where the post request takes place which is:

val response = Http(MY_END_POINT).header("SOME_HEADER",SOME_VALUE).header("SOME_HEADER", SOME_VALUE).header("SOME_HEADER", SOME_VALUE).postMulti(MultiPart("SOME_VALUE", "", "SOME_VALUE", "SOME_VALUE"), MultiPart("SOME_VALUE", "", "SOME_VALUE", SOME_VALUE), MultiPart("SOME_VALUE", "", "SOME_VALUE", SOME_VALUE)).auth(USER, PASS).option(HttpOptions.connTimeout(10000)).option(HttpOptions.readTimeout(120000)).asString

I haven't set context length anywhere for the post request and the failure happens randomly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant