Fast-Android-Networking
Fast-Android-Networking copied to clipboard
Larger video files downloading failed with error
onError called with : com.androidnetworking.error.ANError: com.androidnetworking.error.ANError: java.net.ProtocolException: unexpected end of stream
D/SplashActivity$startDownload: bytesDownloaded : 5079040 totalBytes : 78672912 D/SplashActivity$startDownload: onError called with : com.androidnetworking.error.ANError: com.androidnetworking.error.ANError: java.net.ProtocolException: unexpected end of stream
To be honest you should debug this more because this doesn't look like a "library" issue... This library is made on top of OkHttp Networking Layer. So if there is some download issue OkHttp has to have it too and I don't believe this is the case... Your issue can have various causes, most probably some network issue. I would suggest do more testing and also don't forget that you can initialize it with your own ok http client.
Initializing it with some customization , as it uses OkHttp as networking layer, you can pass custom okHttpClient while initializing it, that what I always do and never had issues with downloads for few years in various projects....
// Adding an Network Interceptor for Debugging purpose : OkHttpClient okHttpClient = new OkHttpClient() .newBuilder() .addNetworkInterceptor(new StethoInterceptor()) .build(); AndroidNetworking.initialize(getApplicationContext(),okHttpClient);
Hi @rene-dohan I'll try one more time with given configuration. FYI am using wifi not mobile network. I have confident there is not network fluctuation while downloading this file. Even am tried PRDownloader also its unable to download this file (https://github.com/MindorksOpenSource/PRDownloader/issues/163).
Same error :
D/SplashActivity$startDownload: 6533120/78672912 D/SplashActivity$startDownload: onError called with com.androidnetworking.error.ANError: java.net.ProtocolException: unexpected end of stream
D/SplashActivity$startDownload: 12779520/78672912 D/SplashActivity$startDownload: onError called with com.androidnetworking.error.ANError: java.net.ProtocolException: unexpected end of stream
D/SplashActivity$startDownload: 10301440/78672912 D/SplashActivity$startDownload: onError called with com.androidnetworking.error.ANError: java.net.ProtocolException: unexpected end of stream
I had tried multiple times with same file same issue repeated. I had connected with Wifi of 50mbps fibernet connection.
Please check this, might be the same issue.
Hi @amitshekhariitbhu , am not added any configuration. But as per your suggestion am added below code :
Application class ::
// Adding an Network Interceptor for Debugging purpose : OkHttpClient okHttpClient = new OkHttpClient() .newBuilder() .addNetworkInterceptor(new StethoInterceptor()) .build(); AndroidNetworking.initialize(getApplicationContext(),okHttpClient);
if (BuildConfig.DEBUG) {
AndroidNetworking.enableLogging(HttpLoggingInterceptor.Level.BASIC);
}
Same issue raised again : D/AndroidNetworking :: 5888000 / 78672912 D/AndroidNetworking onError  :: onError called com.androidnetworking.error.ANError: com.androidnetworking.error.ANError: java.net.ProtocolException: unexpected end of stream
D/AndroidNetworking :: 7874560 / 78672912 D/AndroidNetworking onError  :: onError called com.androidnetworking.error.ANError: com.androidnetworking.error.ANError: java.net.ProtocolException: unexpected end of stream
D/AndroidNetworking :: 7618560 / 78672912 D/AndroidNetworking onError  :: onError called com.androidnetworking.error.ANError: com.androidnetworking.error.ANError: java.net.ProtocolException: unexpected end of stream
I believe the most obvious way is first check if it happens to some standard host like google firebase... You can easily setup and upload large file to firebase store so you will see if you can download large files or not. If it happens there its as you say library issue but you understand that okhttp is very popular library... So I believe it to be that host issue, you just have to be shure to investigate more what is the case. If it works on firebase you know that it's not fixabble on client side. You can also upload by executing that same request by curl or by postman... You just need to first know where is the issue because now I cannot see why "unexpected end of stream" happened. Thats what I would do in your case.
PS: I am not this library developer or anything I just respond you like developer buddy ;)
need high version okhttp impl