问题描述
我目前使用的改造Android作为我的网络通信。当张贴到我的后端服务器映像,服务器上载的中间,然后改造超时与SocketTimeoutException。
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.
我已经加入了OKhttp库的一些建议,并仍然得到超时。
I have added the OKhttp library as some have suggested and still getting the timeout.
目前IMG大小750KB左右,因为我攀登下来。
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?
感谢
推荐答案
也许尝试用 setReadTimeout 您OkHttpClient;注意,设置为0表示要永不超时。
Perhaps try changing the timeout with setReadTimeout on your OkHttpClient; note that a setting of 0 indicates to never time out.
奖励:如果你需要帮助找出适当的设置,你可以阅读的从异常超时之前,也找出当前的默认读取超时与 getReadTimeout 。
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.
这篇关于改造SocketTimeoutException - 上传图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!