Android HttpUrlConnection EOFException

前端 未结 7 1601
自闭症患者
自闭症患者 2020-12-03 06:36

I would like to know if there are known issues on Android with HttpUrlConnection and POST requests. We are experiencing intermittent EOFExceptions when maki

相关标签:
7条回答
  • 2020-12-03 07:33

    Yes. There is a problem in the Android platform, specifically, in Android libcore with version 4.1-4.3.

    The problem is introduced in this commit: https://android.googlesource.com/platform/libcore/+/b2b02ac6cd42a69463fd172531aa1f9b9bb887a8

    Android 4.4 switched http lib to "okhttp" which doesn't have this problem.

    Problem explained as follow:

    On android 4.1-4.3, when you are using URLConnection/HttpURLConnection to POST with "ChunkedStreamingMode" or "FixedLengthStreamingMode" set, URLConnection/HttpURLConnection will not do silent retry if the reused connection is stale. You should retry POST at most "http.maxConnections+1" times in your code, just as previous answers suggest.

    0 讨论(0)
提交回复
热议问题