SocketTimeoutException when trying to upload a file
See original GitHub issueI am using fuel and fuel-android 1.12.0 I keep getting the following error when trying to upload a file.
This is the response:
<-- -1 (https://myurlhere.com)
Response :
Length : 0
Body : (empty)
Headers : (0)
This is the result
[Failure: java.net.SocketTimeoutException: Read timed out]
The file I am trying to upload is a bitmap that I am scaling then compressing:
val file = File.createTempFile( "file", ".png")
val fOut = FileOutputStream(file)
val height = (bitmap.height * 128 / bitmap.width)
val newBitmap = Bitmap.createScaledBitmap(bitmap, 128, height, true)
newBitmap.compress(Bitmap.CompressFormat.PNG, 85, fOut)
fOut.flush()
fOut.close()
My request looks like this
Fuel.upload(url)
.source { request, url -> file }
.name { "file" }
.responseString { request, response, result ->
handler(response.statusCode)
}
I have tried changing the default timeout and readtimeout but that hasn’t had any affect.
This works in the emulator, however when I try it on a device I get the above response and result. I have tried different devices running different version of Android, from Android 21 to 26 all with the same outcome. It’s not even hitting the server that the url points to.
I was wondering if anyone had any suggestions on what I can do to fix this?
Issue Analytics
- State:
- Created 6 years ago
- Comments:10
Top Results From Across the Web
java.net.SocketTimeoutException error while trying to install ...
When trying to install an add-on *.jar file in Jira via the upload app button from the page ⚙ > Manage Apps >...
Read more >android - Modify File Upload Socket Timeout and Exception
It attempts to add a more resilient network layer to the stack. Its been my experience they all try to pretend a connection...
Read more >File Uploading - SocketTimeoutException: Read timed out
Hey, this usually occurs because of an unreliable internet connection. Also, note, 50mb is a large file! Are you on wifi or a...
Read more >SocketTimeoutException:Read timed out error-check in file ...
sendRequest(userContext, inputBinder); where 'is' is the inputStream which has the file data that needs to be uploaded. ... I have tried to ...
Read more >SonarQube report upload throwing SocketTimeOutException
When i try to execute sonar analysis on bigger project having more than 260 java source code files. the Sonar scanner completed the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@andrewmarmion It seems like you are compressing bitmap and it may reduce the quality. Was looking for a better way to do so and found below one which might help you in your case.
There is no maximum file upload size. Postman will limit the number of concurrent uploads automatically. Your browser limits it to ~6 (depending on the browser and version). Fuel does not limit it.