HttpsURLConnection POST request of a large file throws an IOException in a few minutes

I’ve been working on this error for several days now and cannot solve it.

I wrote an HttpsURLConnection client to download large files (> 1 GB) using POST requests. I also implemented a server using com.sun.net.httpserver.HttpServer. Since the files are quite large, I have to use the settings: setFixedLengthStreamingMode / setChunkedStreamingMode in my connection (the error is reproduced using either). Please note that I also use the HTTPS connection for download.

I upload a file to several servers at the same time (a separate stream for each HTTP client connected to another server). I set a limit on simultaneous downloads, so every time only X threads have an open UrlConnection (the error was reproduced using X = [1..4]). (The rest of the threads are waiting for the semaphore)

My problem is this: When the download takes less than 5 minutes (less than 4:50 minutes to be exact), everything works fine. If the first batch of threads takes more than 5 minutes, an exception is thrown for each active thread:

java.io.IOException: error entering body of the request to the server at sun.net.www.protocol.http.HttpURLConnection $ StreamingOutputStream.checkError (Unknown source) at sun.net.www.protocol.http.HttpURLConnection $ StreamingOutputStream.write (Unknown source)

HttpURLConnection. [OutputStream.write(, 0, );]

( 5 ). , , , , . ( , 5 ...)

/ / . , , , . 20-40 , , " " IOException.

TCP/IP wirehark , FIN , , . (, )

, . ( java.net.URLConnection HTTP-)

, ? ? ?

.

P.S , ... , .

+5

All Articles