问题
I'm currently using Retrofit for Android as my network communications. When POSTing to my backend server an image, the server is in the middle of the upload and then retrofit "times out" with SocketTimeoutException.
I have added the OKhttp library as some have suggested and still getting the timeout.
The current img sizes are around 750kb because I have scaled them down.
Is there an appropriate way to changes the amount of time until a timeout for retrofit? Or is there a better way to upload images to a server?
Thanks
回答1:
Perhaps try changing the timeout with setReadTimeout on your OkHttpClient; note that a setting of 0 indicates to never time out.
Bonus: if you need help figuring out an appropriate setting, you can read the bytes successfully transferred before the timeout from the exception, and also find out the current default read timeout with getReadTimeout.
来源:https://stackoverflow.com/questions/23347898/retrofit-sockettimeoutexception-uploading-image