0

This error java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer) freeze my fragment besides progressBar keeps turning even after displaying image, how do i fix this ?

    10-09 16:10:15.933: W/System.err(19358): java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
    10-09 16:10:15.937: W/System.err(19358):    at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:552)
    10-09 16:10:15.937: W/System.err(19358):    at libcore.io.IoBridge.recvfrom(IoBridge.java:516)
    10-09 16:10:15.941: W/System.err(19358):    at java.net.PlainSocketImpl.read(PlainSocketImpl.java:488)
    10-09 16:10:15.941: W/System.err(19358):    at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46)
    10-09 16:10:15.945: W/System.err(19358):    at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:240)
    10-09 16:10:15.945: W/System.err(19358):    at java.io.BufferedInputStream.read(BufferedInputStream.java:304)
    10-09 16:10:15.945: W/System.err(19358):    at libcore.net.http.FixedLengthInputStream.read(FixedLengthInputStream.java:45)
    10-09 16:10:15.957: W/System.err(19358):    at java.io.InputStream.read(InputStream.java:163)
    10-09 16:10:15.972: W/System.err(19358):    at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:142)
    10-09 16:10:15.976: W/System.err(19358):    at java.io.BufferedInputStream.read(BufferedInputStream.java:309)
    10-09 16:10:15.976: W/System.err(19358):    at java.io.FilterInputStream.read(FilterInputStream.java:138)
    10-09 16:10:15.976: W/System.err(19358):    at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
    10-09 16:10:15.980: W/System.err(19358):    at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:527)
    10-09 16:10:15.980: W/System.err(19358):    at com.nostra13.universalimageloader.core.ImageDecoder.decode(ImageDecoder.java:83)
    10-09 16:10:15.980: W/System.err(19358):    at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.saveImageOnDisc(LoadAndDisplayImageTask.java:219)
    10-09 16:10:15.980: W/System.err(19358):    at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:139)
    10-09 16:10:15.992: W/System.err(19358):    at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:72)
    10-09 16:10:15.996: W/System.err(19358):    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
    10-09 16:10:15.996: W/System.err(19358):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
    10-09 16:10:15.996: W/System.err(19358):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
    10-09 16:10:15.996: W/System.err(19358):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
    10-09 16:10:15.996: W/System.err(19358):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
    10-09 16:10:16.000: W/System.err(19358):    at java.lang.Thread.run(Thread.java:856)
    10-09 16:10:16.004: W/System.err(19358): Caused by: libcore.io.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by peer)
    10-09 16:10:16.008: W/System.err(19358):    at libcore.io.Posix.recvfromBytes(Native Method)
    10-09 16:10:16.008: W/System.err(19358):    at libcore.io.Posix.recvfrom(Posix.java:131)
    10-09 16:10:16.012: W/System.err(19358):    at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:164)
    10-09 16:10:16.012: W/System.err(19358):    at libcore.io.IoBridge.recvfrom(IoBridge.java:513)
    10-09 16:10:16.012: W/System.err(19358):    ... 21 more
    10-09 16:10:16.015: D/skia(19358): ---- read threw an exception
    10-09 16:10:16.015: D/skia(19358): --- decoder->decode returned false
    10-09 16:10:16.015: E/ImageLoader(19358): null
    10-09 16:10:16.015: E/ImageLoader(19358): java.lang.NullPointerException
    10-09 16:10:16.015: E/ImageLoader(19358):   at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.saveImageOnDisc(LoadAndDisplayImageTask.java:222)
    10-09 16:10:16.015: E/ImageLoader(19358):   at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:139)
    10-09 16:10:16.015: E/ImageLoader(19358):   at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:72)
    10-09 16:10:16.015: E/ImageLoader(19358):   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
    10-09 16:10:16.015: E/ImageLoader(19358):   at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
    10-09 16:10:16.015: E/ImageLoader(19358):   at java.util.concurrent.FutureTask.run(FutureTask.java:137)
    10-09 16:10:16.015: E/ImageLoader(19358):   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
    10-09 16:10:16.015: E/ImageLoader(19358):   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
    10-09 16:10:16.015: E/ImageLoader(19358):   at java.lang.Thread.run(Thread.java:856)
    10-09 16:11:04.609: D/dalvikvm(19358): Debugger has detached; object registry had 1 entries

I am using Image Universal Loader like this :

 public void imageHolder(String url, ImageView iv)
{
    File cacheDir = StorageUtils.getOwnCacheDirectory(context, "UniversalImageLoader/Cache");

    ImageLoader imageLoader = ImageLoader.getInstance();

    ImageLoaderConfiguration config = new     ImageLoaderConfiguration.Builder(context)
//      .memoryCacheExtraOptions(480, 800) 
//      .discCacheExtraOptions(480, 800, CompressFormat.JPEG, 50) 
    .threadPoolSize(3)
    .threadPriority(Thread.NORM_PRIORITY - 1)
    .denyCacheImageMultipleSizesInMemory()
    .offOutOfMemoryHandling()
    .memoryCache(new UsingFreqLimitedMemoryCache(2 * 1024 * 1024)) 
    .discCache(new UnlimitedDiscCache(cacheDir)) 
    .discCacheFileNameGenerator(new HashCodeFileNameGenerator())
    .imageDownloader(new URLConnectionImageDownloader(5 * 1000, 20 * 1000)) 
    .defaultDisplayImageOptions(DisplayImageOptions.createSimple())
    .enableLogging()
    .build();
    imageLoader.init(config);
    // Creates display image options for custom display task (all options are optional)
    DisplayImageOptions options = new DisplayImageOptions.Builder()
    .showStubImage(R.drawable.error)
    .showImageForEmptyUri(R.drawable.error)
    .cacheInMemory()
    .cacheOnDisc()
    .imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2)
    .build();
    // Load and display image
    imageLoader.displayImage(url, iv, options, new ImageLoadingListener() {
        @Override
        public void onLoadingStarted() {
            fv.pb.setVisibility(View.VISIBLE);          
        }
        @Override
        public void onLoadingFailed(FailReason failReason) {
            fv.pb.setVisibility(View.GONE);             
        }
        @Override
        public void onLoadingComplete(Bitmap loadedImage) {
            fv.pb.setVisibility(View.GONE);             
        }
        @Override
        public void onLoadingCancelled() {
            fv.pb.setVisibility(View.GONE);             
        }
    });
}
4

0 回答 0