Android Asynchronous Networking and Image Loading

Related tags

Image Loader ion
Overview

Android Asynchronous Networking and Image Loading

Download

Features

Samples

The included documented ion-sample project includes some samples that demo common Android network operations:

  • Twitter Client Sample
    • Download JSON from a server (twitter feed)
    • Populate a ListView Adapter and fetch more data as you scroll to the end
    • Put images from a URLs into ImageViews (twitter profile pictures)
  • File Download with Progress Bar Sample
  • Get JSON and show images with the Image Search Sample

More Examples

Looking for more? Check out the examples below that demonstrate some other common scenarios. You can also take a look at 30+ ion unit tests in the ion-test.

Get JSON

Ion.with(context)
.load("http://example.com/thing.json")
.asJsonObject()
.setCallback(new FutureCallback<JsonObject>() {
   @Override
    public void onCompleted(Exception e, JsonObject result) {
        // do stuff with the result or error
    }
});

Post JSON and read JSON

JsonObject json = new JsonObject();
json.addProperty("foo", "bar");

Ion.with(context)
.load("http://example.com/post")
.setJsonObjectBody(json)
.asJsonObject()
.setCallback(new FutureCallback<JsonObject>() {
   @Override
    public void onCompleted(Exception e, JsonObject result) {
        // do stuff with the result or error
    }
});

Post application/x-www-form-urlencoded and read a String

Ion.with(getContext())
.load("https://koush.clockworkmod.com/test/echo")
.setBodyParameter("goop", "noop")
.setBodyParameter("foo", "bar")
.asString()
.setCallback(...)

Post multipart/form-data and read JSON with an upload progress bar

Ion.with(getContext())
.load("https://koush.clockworkmod.com/test/echo")
.uploadProgressBar(uploadProgressBar)
.setMultipartParameter("goop", "noop")
.setMultipartFile("archive", "application/zip", new File("/sdcard/filename.zip"))
.asJsonObject()
.setCallback(...)

Download a File with a progress bar

Ion.with(context)
.load("http://example.com/really-big-file.zip")
// have a ProgressBar get updated automatically with the percent
.progressBar(progressBar)
// and a ProgressDialog
.progressDialog(progressDialog)
// can also use a custom callback
.progress(new ProgressCallback() {@Override
   public void onProgress(long downloaded, long total) {
       System.out.println("" + downloaded + " / " + total);
   }
})
.write(new File("/sdcard/really-big-file.zip"))
.setCallback(new FutureCallback<File>() {
   @Override
    public void onCompleted(Exception e, File file) {
        // download done...
        // do stuff with the File or error
    }
});

Setting Headers

Ion.with(context)
.load("http://example.com/test.txt")
// set the header
.setHeader("foo", "bar")
.asString()
.setCallback(...)

Load an image into an ImageView

// This is the "long" way to do build an ImageView request... it allows you to set headers, etc.
Ion.with(context)
.load("http://example.com/image.png")
.withBitmap()
.placeholder(R.drawable.placeholder_image)
.error(R.drawable.error_image)
.animateLoad(spinAnimation)
.animateIn(fadeInAnimation)
.intoImageView(imageView);

// but for brevity, use the ImageView specific builder...
Ion.with(imageView)
.placeholder(R.drawable.placeholder_image)
.error(R.drawable.error_image)
.animateLoad(spinAnimation)
.animateIn(fadeInAnimation)
.load("http://example.com/image.png");

The Ion Image load API has the following features:

  • Disk and memory caching
  • Bitmaps are held via weak references so memory is managed very efficiently
  • ListView Adapter recycling support
  • Bitmap transformations via the .transform(Transform)
  • Animate loading and loaded ImageView states
  • DeepZoom for extremely large images

Futures

All operations return a custom Future that allows you to specify a callback that runs on completion.

public interface Future<T> extends Cancellable, java.util.concurrent.Future<T> {
    /**
     * Set a callback to be invoked when this Future completes.
     * @param callback
     * @return
     */
    public Future<T> setCallback(FutureCallback<T> callback);
}

Future<String> string = Ion.with(context)
.load("http://example.com/string.txt")
.asString();

Future<JsonObject> json = Ion.with(context)
.load("http://example.com/json.json")
.asJsonObject();

Future<File> file = Ion.with(context)
.load("http://example.com/file.zip")
.write(new File("/sdcard/file.zip"));

Future<Bitmap> bitmap = Ion.with(context)
.load("http://example.com/image.png")
.intoImageView(imageView);

Cancelling Requests

Futures can be cancelled by calling .cancel():

bitmap.cancel();
json.cancel();

Blocking on Requests

Though you should try to use callbacks for handling requests whenever possible, blocking on requests is possible too. All Futures have a Future.get() method that waits for the result of the request, by blocking if necessary.

JsonObject json = Ion.with(context)
.load("http://example.com/thing.json").asJsonObject().get();

Seamlessly use your own Java classes with Gson

public static class Tweet {
    public String id;
    public String text;
    public String photo;
}

public void getTweets() throws Exception {
    Ion.with(context)
    .load("http://example.com/api/tweets")
    .as(new TypeToken<List<Tweet>>(){})
    .setCallback(new FutureCallback<List<Tweet>>() {
       @Override
        public void onCompleted(Exception e, List<Tweet> tweets) {
          // chirp chirp
        }
    });
}

Logging

Wondering why your app is slow? Ion lets you do both global and request level logging.

To enable it globally:

Ion.getDefault(getContext()).configure().setLogging("MyLogs", Log.DEBUG);

Or to enable it on just a single request:

Ion.with(context)
.load("http://example.com/thing.json")
.setLogging("MyLogs", Log.DEBUG)
.asJsonObject();

Log entries will look like this:

D/MyLogs(23153): (0 ms) http://example.com/thing.json: Executing request.
D/MyLogs(23153): (106 ms) http://example.com/thing.json: Connecting socket
D/MyLogs(23153): (2985 ms) http://example.com/thing.json: Response is not cacheable
D/MyLogs(23153): (3003 ms) http://example.com/thing.json: Connection successful

Request Groups

By default, Ion automatically places all requests into a group with all the other requests created by that Activity or Service. Using the cancelAll(Activity) call, all requests still pending can be easily cancelled:

Future<JsonObject> json1 = Ion.with(activity, "http://example.com/test.json").asJsonObject();
Future<JsonObject> json2 = Ion.with(activity, "http://example.com/test2.json").asJsonObject();

// later... in activity.onStop
@Override
protected void onStop() {
    Ion.getDefault(activity).cancelAll(activity);
    super.onStop();
}

Ion also lets you tag your requests into groups to allow for easy cancellation of requests in that group later:

Object jsonGroup = new Object();
Object imageGroup = new Object();

Future<JsonObject> json1 = Ion.with(activity)
.load("http://example.com/test.json")
// tag in a custom group
.group(jsonGroup)
.asJsonObject();

Future<JsonObject> json2 = Ion.with(activity)
.load("http://example.com/test2.json")
// use the same custom group as the other json request
.group(jsonGroup)
.asJsonObject();

Future<Bitmap> image1 = Ion.with(activity)
.load("http://example.com/test.png")
// for this image request, use a different group for images
.group(imageGroup)
.intoImageView(imageView1);

Future<Bitmap> image2 = Ion.with(activity)
.load("http://example.com/test2.png")
// same imageGroup as before
.group(imageGroup)
.intoImageView(imageView2);

// later... to cancel only image downloads:
Ion.getDefault(activity).cancelAll(imageGroup);

Proxy Servers (like Charles Proxy)

Proxy server settings can be enabled all Ion requests, or on a per request basis:

// proxy all requests
Ion.getDefault(context).configure().proxy("mycomputer", 8888);

// or... to proxy specific requests
Ion.with(context)
.load("http://example.com/proxied.html")
.proxy("mycomputer", 8888)
.getString();

Using Charles Proxy on your desktop computer in conjunction with request proxying will prove invaluable for debugging!

Viewing Received Headers

Ion operations return a ResponseFuture, which grant access to response properties via the Response object. The Response object contains the headers, as well as the result:

Ion.with(getContext())
.load("http://example.com/test.txt")
.asString()
.withResponse()
.setCallback(new FutureCallback<Response<String>>() {
    @Override
    public void onCompleted(Exception e, Response<String> result) {
        // print the response code, ie, 200
        System.out.println(result.getHeaders().code());
        // print the String that was downloaded
        System.out.println(result.getResult());
    }
});

Get Ion

Maven
<dependency>
   <groupId>com.koushikdutta.ion</groupId>
   <artifactId>ion</artifactId>
   <version>(insert latest version)</version>
</dependency>
Gradle
dependencies {
    compile 'com.koushikdutta.ion:ion:(insert latest version)'
}
Local Checkout (with AndroidAsync dependency)
git clone git://github.com/koush/AndroidAsync.git
git clone git://github.com/koush/ion.git
cd ion/ion
ant -Dsdk.dir=$ANDROID_HOME release install

Jars are at

  • ion/ion/bin/classes.jar
  • AndroidAsync/AndroidAsync/bin/classes.jar

Hack in Eclipse

git clone git://github.com/koush/AndroidAsync.git
git clone git://github.com/koush/ion.git
  • Import the project from AndroidAsync/AndroidAsync into your workspace
  • Import all the ion projects (ion/ion, ion/ion-sample) into your workspace.

Projects using ion

There's hundreds of apps using ion. Feel free to contact me or submit a pull request to add yours to this list.

Comments
  • SSL Handshake issue

    SSL Handshake issue

    Hi. I'm having an issue with the SSLContext and Ion. Everything works fine until i run an image upload script i recently created using Ion. The code i'm using is below:

    Response<String> response = Ion.with(ctx)
                        .load(url)
                        .setHeader(h.toArray())
                        .uploadProgressHandler(new ProgressCallback()
                        {
                            @Override
                            public void onProgress(long transferred, long total) {
                                publishProgress((int) ((transferred / (float) total) * 100));
                            }
                        })
                        .setMultipartFile("upload", mime, file)
                        .asString()
                        .withResponse()
                        .get();
    

    This appears to work as expected. However, as soon as i start the process, the following can be seen in logcat:

    10-24 16:32:29.895    8214-9140/com.myapp.debug D/dalvikvm﹕ Trying to load lib /data/app-lib/com.myapp.debug-2/libgmscore.so 0x4265d778
    10-24 16:32:29.903    8214-9140/com.myapp.debug E/dalvikvm﹕ dlopen("/data/app-lib/com.myapp.debug-2/libgmscore.so") failed: dlopen failed: library "/data/app-lib/com.myapp.debug-2/libgmscore.so" not found
    10-24 16:32:29.903    8214-9140/com.myapp.debug E/ProviderInstaller﹕ Unable to load native code from /data/app-lib/com.myapp.debug-2/libgmscore.so
    10-24 16:32:29.903    8214-9140/com.myapp.debug D/dalvikvm﹕ Trying to load lib /data/app-lib/com.google.android.gms-2/libgmscore.so 0x4265d778
    10-24 16:32:29.919    8214-9140/com.myapp.debug D/dalvikvm﹕ Added shared lib /data/app-lib/com.google.android.gms-2/libgmscore.so 0x4265d778
    10-24 16:32:29.919    8214-9140/com.myapp.debug D/dalvikvm﹕ No JNI_OnLoad found in /data/app-lib/com.google.android.gms-2/libgmscore.so 0x4265d778, skipping init
    10-24 16:32:29.919    8214-9140/com.myapp.debug D/dalvikvm﹕ Trying to load lib /data/app-lib/com.myapp.debug-2/libconscrypt_gmscore_jni.so 0x4265d778
    10-24 16:32:29.919    8214-9140/com.myapp.debug E/dalvikvm﹕ dlopen("/data/app-lib/com.myapp.debug-2/libconscrypt_gmscore_jni.so") failed: dlopen failed: library "/data/app-lib/com.myapp.debug-2/libconscrypt_gmscore_jni.so" not found
    10-24 16:32:29.926    8214-9140/com.myapp.debug E/ProviderInstaller﹕ Unable to load native code from /data/app-lib/com.myapp.debug-2/libconscrypt_gmscore_jni.so
    10-24 16:32:29.926    8214-9140/com.myapp.debug D/dalvikvm﹕ Trying to load lib /data/app-lib/com.google.android.gms-2/libconscrypt_gmscore_jni.so 0x4265d778
    10-24 16:32:29.926    8214-9140/com.myapp.debug D/dalvikvm﹕ Added shared lib /data/app-lib/com.google.android.gms-2/libconscrypt_gmscore_jni.so 0x4265d778
    10-24 16:32:30.012    8214-9140/com.myapp.debug D/dalvikvm﹕ Trying to load lib /data/app-lib/com.google.android.gms-2/libgmscore.so 0x4265d778
    10-24 16:32:30.012    8214-9140/com.myapp.debug D/dalvikvm﹕ Shared lib '/data/app-lib/com.google.android.gms-2/libgmscore.so' already loaded in same CL 0x4265d778
    10-24 16:32:30.012    8214-9140/com.myapp.debug D/dalvikvm﹕ Trying to load lib /data/app-lib/com.google.android.gms-2/libconscrypt_gmscore_jni.so 0x4265d778
    10-24 16:32:30.012    8214-9140/com.myapp.debug D/dalvikvm﹕ Shared lib '/data/app-lib/com.google.android.gms-2/libconscrypt_gmscore_jni.so' already loaded in same CL 0x4265d778
    10-24 16:32:30.036    8214-9140/com.myapp.debug I/ProviderInstaller﹕ Installed default security provider GmsCore_OpenSSL
    

    It then finishes successfully. Then, as soon as i try to connect to my own server again, i get the following error:

    10-24 16:32:35.239    8214-8910/com.myapp.debug W/MyApp: ImageLoader: Error while fetching image, response code: -1
        javax.net.ssl.SSLHandshakeException: Handshake failed
                at com.google.android.gms.org.conscrypt.OpenSSLSocketImpl.startHandshake(SourceFile:374)
                at libcore.net.http.HttpConnection.setupSecureSocket(HttpConnection.java:209)
                at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:478)
                at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:442)
                at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:290)
                at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:240)
                at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:282)
                at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:497)
                at libcore.net.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:134)
                ...
         Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x59b5dc28: Failure in SSL library, usually a protocol error
        error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external/openssl/ssl/s23_clnt.c:762 0x611b3485:0x00000000)
                at com.google.android.gms.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
                at com.google.android.gms.org.conscrypt.OpenSSLSocketImpl.startHandshake(SourceFile:302)
                ... 14 more
    

    And if i then want to upload another image using the same Ion process, i get the following:

    java.lang.RuntimeException: java.lang.IllegalStateException: SSLContext is not initialized.
        at com.koushikdutta.async.AsyncServer.runLoop(SourceFile:797)
        at com.koushikdutta.async.AsyncServer.run(SourceFile:608)
        at com.koushikdutta.async.AsyncServer.access$700(SourceFile:37)
        at com.koushikdutta.async.AsyncServer$13.run(SourceFile:557)
    Caused by: java.lang.IllegalStateException: SSLContext is not initialized.
        at org.apache.harmony.xnet.provider.jsse.SSLContextImpl.engineCreateSSLEngine(SSLContextImpl.java:125)
        at javax.net.ssl.SSLContext.createSSLEngine(SSLContext.java:248)
        at com.koushikdutta.async.http.AsyncSSLSocketMiddleware.createConfiguredSSLEngine(SourceFile:63)
        at com.koushikdutta.async.http.AsyncSSLSocketMiddleware.tryHandshake(SourceFile:82)
        at com.koushikdutta.async.http.AsyncSSLSocketMiddleware$2.onConnectCompleted(SourceFile:95)
        at com.koushikdutta.async.AsyncServer.runLoop(SourceFile:794)
        ... 3 more
    

    It happens every time. Any ideas?

    opened by elroid 47
  • Timeout on upload POST

    Timeout on upload POST

    Hi I'm setting the timeout to Ion.with(context, url).... ion.setTimeout(60 * 60 * 1000);

    but I get timouts exception anyway. is the timeout only for receiving data? because I get it when uploading a lot of data, when doing a POST. is there anyway to set the timeout on that case?

    TIA!

    opened by UXDart 39
  • connection closed before response completed with download picture url

    connection closed before response completed with download picture url

    hello, I have an issue with one of my apps, and I have no idea how to resolve it: the url seems to be for downloading and not for showing the picture ( if i launch url in the browser the picture is downloaded instead of shown). my code :

     Ion.with(ficheImageViewS9)
                   .load(Utils.getBaseUrl(getApplicationContext()) + getString(
                           R.string.PIECE_JOINTE_URL) + signalement.getPhoto()
                                                                   .getIdPhoto() + Utils.getAuthentificationParams(
                           getApplicationContext()));
    

    and verbose log :

    06-12 11:26:56.708  24770-24770/com.mpm.osis D/PHOToDownalod﹕ (0 ms) https://test.extranet.myUrl.fr/rest/piecejointe/3579?login=mylogin&password=***&idSession=123456&canal=MOBILE: preparing request
    06-12 11:26:56.708  24770-24770/com.mpm.osis I/PHOToDownalod﹕ (0 ms) https://test.extranet.myUrl.fr/rest/piecejointe/3579?login=mylogin&password=***&idSession=123456&canal=MOBILE: Using loader: com.koushikdutta.ion.loader.HttpLoader@43a36e38
    06-12 11:26:56.708  24770-25439/com.mpm.osis D/PHOToDownalod﹕ (0 ms) https://test.extranet.myUrl.fr/rest/piecejointe/3579?login=mylogin&password=***&idSession=123456&canal=MOBILE: Executing request.
    06-12 11:26:56.718  24770-25439/com.mpm.osis V/PHOToDownalod﹕ (3 ms) https://test.extranet.myUrl.fr/rest/piecejointe/3579?login=mylogin&password=***&idSession=123456&canal=MOBILE: Resolving domain and connecting to all available addresses
    06-12 11:26:56.788  24770-25439/com.mpm.osis V/PHOToDownalod﹕ (75 ms) https://test.extranet.myUrl.fr/rest/piecejointe/3579?login=mylogin&password=***&idSession=123456&canal=MOBILE: socket connected
    06-12 11:26:56.788  24770-25439/com.mpm.osis V/PHOToDownalod﹕ (76 ms) https://test.extranet.myUrl.fr/rest/piecejointe/3579?login=mylogin&password=***&idSession=123456&canal=MOBILE:
        GET /rest/piecejointe/3579?login=mylogin&password=***&idSession=123456&canal=MOBILE HTTP/1.1
        Host: test.extranet.myUrl.fr
        User-Agent: Dalvik/1.6.0 (Linux; U; Android 4.4.3; Nexus 5 Build/KTU84M)
        Accept-Encoding: gzip, deflate
        Connection: keep-alive
        Accept: */*
    06-12 11:26:56.948  24770-25439/com.mpm.osis W/System.err﹕ javax.net.ssl.SSLProtocolException: Unexpected message type has been received: 22
    06-12 11:26:56.948  24770-25439/com.mpm.osis W/System.err﹕ at com.android.org.conscrypt.SSLRecordProtocol.unwrap(SSLRecordProtocol.java:360)
    06-12 11:26:56.948  24770-25439/com.mpm.osis W/System.err﹕ at com.android.org.conscrypt.SSLEngineImpl.unwrap(SSLEngineImpl.java:463)
    06-12 11:26:56.948  24770-25439/com.mpm.osis W/System.err﹕ at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:383)
    06-12 11:26:56.948  24770-25439/com.mpm.osis W/System.err﹕ at com.koushikdutta.async.AsyncSSLSocketWrapper$2.onDataAvailable(AsyncSSLSocketWrapper.java:97)
    06-12 11:26:56.948  24770-25439/com.mpm.osis W/System.err﹕ at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:33)
    06-12 11:26:56.958  24770-25439/com.mpm.osis W/System.err﹕ at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:61)
    06-12 11:26:56.958  24770-25439/com.mpm.osis W/System.err﹕ at com.koushikdutta.async.Util.emitAllData(Util.java:20)
    06-12 11:26:56.958  24770-25439/com.mpm.osis W/System.err﹕ at com.koushikdutta.async.AsyncNetworkSocket.onReadable(AsyncNetworkSocket.java:171)
    06-12 11:26:56.958  24770-25439/com.mpm.osis W/System.err﹕ at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:725)
    06-12 11:26:56.958  24770-25439/com.mpm.osis W/System.err﹕ at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:583)
    06-12 11:26:56.958  24770-25439/com.mpm.osis W/System.err﹕ at com.koushikdutta.async.AsyncServer.access$700(AsyncServer.java:36)
    06-12 11:26:56.958  24770-25439/com.mpm.osis W/System.err﹕ at com.koushikdutta.async.AsyncServer$13.run(AsyncServer.java:531)
    06-12 11:26:56.958  24770-25439/com.mpm.osis E/PHOToDownalod﹕ (242 ms) https://test.extranet.myUrl.fr/rest/piecejointe/3579?login=mylogin&password=***&idSession=123456&canal=MOBILE: exception during response
    06-12 11:26:56.958  24770-25439/com.mpm.osis E/PHOToDownalod﹕ connection closed before response completed.
        com.koushikdutta.async.http.ConnectionClosedException: connection closed before response completed.
                at com.koushikdutta.async.http.AsyncHttpResponseImpl$3.onCompleted(AsyncHttpResponseImpl.java:95)
                at com.koushikdutta.async.AsyncSSLSocketWrapper.report(AsyncSSLSocketWrapper.java:382)
                at com.koushikdutta.async.AsyncSSLSocketWrapper.access$100(AsyncSSLSocketWrapper.java:27)
                at com.koushikdutta.async.AsyncSSLSocketWrapper$2.onDataAvailable(AsyncSSLSocketWrapper.java:126)
                at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:33)
                at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:61)
                at com.koushikdutta.async.Util.emitAllData(Util.java:20)
                at com.koushikdutta.async.AsyncNetworkSocket.onReadable(AsyncNetworkSocket.java:171)
                at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:725)
                at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:583)
                at com.koushikdutta.async.AsyncServer.access$700(AsyncServer.java:36)
                at com.koushikdutta.async.AsyncServer$13.run(AsyncServer.java:531)
         Caused by: javax.net.ssl.SSLProtocolException: Unexpected message type has been received: 22
                at com.android.org.conscrypt.SSLRecordProtocol.unwrap(SSLRecordProtocol.java:360)
                at com.android.org.conscrypt.SSLEngineImpl.unwrap(SSLEngineImpl.java:463)
                at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:383)
                at com.koushikdutta.async.AsyncSSLSocketWrapper$2.onDataAvailable(AsyncSSLSocketWrapper.java:97)
                at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:33)
                at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:61)
                at com.koushikdutta.async.Util.emitAllData(Util.java:20)
                at com.koushikdutta.async.AsyncNetworkSocket.onReadable(AsyncNetworkSocket.java:171)
                at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:725)
                at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:583)
                at com.koushikdutta.async.AsyncServer.access$700(AsyncServer.java:36)
                at com.koushikdutta.async.AsyncServer$13.run(AsyncServer.java:531)
    06-12 11:26:56.958  24770-25439/com.mpm.osis E/PHOToDownalod﹕ (244 ms) https://test.extranet.myUrl.fr/rest/piecejointe/3579?login=mylogin&password=***&idSession=123456&canal=MOBILE: Connection error
    06-12 11:26:56.958  24770-25439/com.mpm.osis E/PHOToDownalod﹕ connection closed before response completed.
        com.koushikdutta.async.http.ConnectionClosedException: connection closed before response completed.
                at com.koushikdutta.async.http.AsyncHttpResponseImpl$3.onCompleted(AsyncHttpResponseImpl.java:95)
                at com.koushikdutta.async.AsyncSSLSocketWrapper.report(AsyncSSLSocketWrapper.java:382)
                at com.koushikdutta.async.AsyncSSLSocketWrapper.access$100(AsyncSSLSocketWrapper.java:27)
                at com.koushikdutta.async.AsyncSSLSocketWrapper$2.onDataAvailable(AsyncSSLSocketWrapper.java:126)
                at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:33)
                at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:61)
                at com.koushikdutta.async.Util.emitAllData(Util.java:20)
                at com.koushikdutta.async.AsyncNetworkSocket.onReadable(AsyncNetworkSocket.java:171)
                at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:725)
                at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:583)
                at com.koushikdutta.async.AsyncServer.access$700(AsyncServer.java:36)
                at com.koushikdutta.async.AsyncServer$13.run(AsyncServer.java:531)
         Caused by: javax.net.ssl.SSLProtocolException: Unexpected message type has been received: 22
                at com.android.org.conscrypt.SSLRecordProtocol.unwrap(SSLRecordProtocol.java:360)
                at com.android.org.conscrypt.SSLEngineImpl.unwrap(SSLEngineImpl.java:463)
                at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:383)
                at com.koushikdutta.async.AsyncSSLSocketWrapper$2.onDataAvailable(AsyncSSLSocketWrapper.java:97)
                at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:33)
                at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:61)
                at com.koushikdutta.async.Util.emitAllData(Util.java:20)
                at com.koushikdutta.async.AsyncNetworkSocket.onReadable(AsyncNetworkSocket.java:171)
                at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:725)
                at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:583)
                at com.koushikdutta.async.AsyncServer.access$700(AsyncServer.java:36)
                at com.koushikdutta.async.AsyncServer$13.run(AsyncServer.java:531)
    06-12 11:26:56.958  24770-25439/com.mpm.osis V/PHOToDownalod﹕ (246 ms) https://test.extranet.myUrl.fr/rest/piecejointe/3579?login=mylogin&password=***&idSession=123456&canal=MOBILE: closing out socket (exception)
    
    

    Same url is working with Android-Universal-Image-Loader but I already use Ion in my application and i would like to keep it for all request. have you got a specific workaround for this case ? thanks, and by the way, thanks for this great library .

    opened by sgueniot 37
  • What does this error mean:

    What does this error mean: "Not all data was consumed by Util.emitAllData"?

    I'm using Ion in my Android app to download text, byte arrays, and images.

    For certain downloads (and unfortunately I have not been able to isolate them), the app will crash with a java.lang.RuntimeException with the following message:

    Not all data was consumed by Util.emitAllData
    

    I can see that com.koushikdutta.async.Util is throwing the exception, but I don't understand why. What does the error even mean so I can try to fix it?

    opened by elmehalawi 35
  • No exception on network loss

    No exception on network loss

    It seems this commit caused this issue, or something else after it. https://github.com/koush/ion/commit/fb6229beef8325f2d1f07a589949f37ed2b3065c

    When downloading a file with withResponse().setCallback, the onCompleted callback exception parameter will be null as well as the response.getException when you lose internet connection during the download (either toggle airplane mode or switch from wifi to lte or something)

    opened by nschwermann 35
  • TLS using SNI fails when using conscrypt MW after recent Google Play Services update

    TLS using SNI fails when using conscrypt MW after recent Google Play Services update

    Hi,

    Yesterday a lot of our phones stopped being able to contact our backend. The backend runs on AWS with CloudFront at the front (AWS API gateway actually). Apparently CloudFront uses SNI. This seems to correlate to a recent update of Google Play Services being pushed out because it gradually affected more and more of our phones.

    When contacting our EC2 servers directly, it works fine, but when going through CloudFront it fails. Before the Google Play Service update both worked fine for months.

    After digging around I found a workaround - disabling conscrypt MW in Ion solves the issue.

    But is this the proper way to solve this or should Ion add some missing support for SNI in combination with conscrypt? I do not really understand the consequences of disabling conscrypt, but some sources indicate it's not a good idea.

    @koush do you have any info on what the root cause is here and what the best solution might be to be able to use Ion together with TLS 1.2/SNI without any hacks or workarounds?

    For reference I also put this Q&A on SO: https://stackoverflow.com/questions/44307801/android-app-using-ion-for-https-requests-fail-seemingly-after-google-play-servi

    opened by henhal 34
  • Ion image loading is not smooth

    Ion image loading is not smooth

    Previously we were using Picasso (http://square.github.io/picasso/) library to load, manage and display images.

    This is the video that show differences between Ion and Picasso: https://www.dropbox.com/s/ima3rwckwqinp8g/VIDEO0007.mp4

    On the left you have N4 with Ion and on the right you have a Galaxy S4 using Picasso. The code is the same, we've just changed the line of code that is loading the image.

    Picasso:

    Picasso.with( itemHolder.root.getContext() ).load( imageUrl ).fit().placeholder( R.drawable.placeholder_thumb ).into( itemHolder.image );
    

    Ion:

    Ion.with(itemHolder.image)
                    .placeholder(R.drawable.placeholder_thumb)
                    .load( imageUrl );
    

    itemHolder is private static class that holds all row images/texts and so on

    opened by StErMi 32
  • OutOfMemory error for allocating bytebuffer

    OutOfMemory error for allocating bytebuffer

    I'm getting a lot of crashes from my app due to the following error: java.lang.OutOfMemoryError at java.nio.ByteBuffer.allocate(ByteBuffer.java:56) at com.koushikdutta.async.ByteBufferList.obtain(SourceFile:473) at com.koushikdutta.async.http.ResponseCacheMiddleware$BodySpewer.a(SourceFile:410) at com.koushikdutta.async.http.ResponseCacheMiddleware$BodySpewer$1.run(SourceFile:431) at com.koushikdutta.async.AsyncServer.a(SourceFile:675) at com.koushikdutta.async.AsyncServer.c(SourceFile:689) at com.koushikdutta.async.AsyncServer.b(SourceFile:600) at com.koushikdutta.async.AsyncServer.a(SourceFile:37) at com.koushikdutta.async.AsyncServer$13.run(SourceFile:549)

    I'm not sure where this happens.

    opened by raylee4204 30
  • Images stop loading

    Images stop loading

    I have an issue now where after running an app for a while images stop loading. Checking the debug log the requests seem to go OK, but nothing gets loaded into the ImageView. The only way to resolve this issue is to totally kill the app and restart.

    The requests are of this form:

    Ion.getInstance(context, "thumb_loader").build(holder.nowIcon).resize(250, 141)
    .centerCrop()
    .placeholder(R.drawable.default_thumb).error(R.drawable.default_thumb)
    .load(cursor.getString(cursor.getColumnIndex("now_image")))
    .setCallback(new FutureCallback<ImageView>() {
    
        @Override
        public void onCompleted(Exception e, ImageView result) {
            if (e != null) {
                e.printStackTrace();
            }
        }
    });
    

    The log comes out as

    D/Thumb Loader(29401): (0 ms) http://manager.thumbnails.simplestream.com/imagesizecacheurl.php?path=aHR0cDovL2kuZGlnaWd1aWRlLnR2L3VwLzEzMDgvODk3Njg1LUhvd3RvYmUtMTM3NjY0NjE5ODAuanBn&width=320: preparing request
    D/Thumb Loader(29401): (0 ms) http://manager.thumbnails.simplestream.com/imagesizecacheurl.php?path=aHR0cDovL2kuZGlnaWd1aWRlLnR2L3VwLzEzMDgvODk3Njg1LUhvd3RvYmUtMTM3NjY0NjE5ODAuanBn&width=320: Executing request.
    I/Thumb Loader(29401): (0 ms) http://manager.thumbnails.simplestream.com/imagesizecacheurl.php?path=aHR0cDovL2kuZGlnaWd1aWRlLnR2L3VwLzEzMDgvODk3Njg1LUhvd3RvYmUtMTM3NjY0NjE5ODAuanBn&width=320: Using loader: com.koushikdutta.ion.loader.HttpLoader@42441198
    V/Thumb Loader(29401): (1 ms) http://manager.thumbnails.simplestream.com/imagesizecacheurl.php?path=aHR0cDovL2kuZGlnaWd1aWRlLnR2L3VwLzEzMDgvODk3Njg1LUhvd3RvYmUtMTM3NjY0NjE5ODAuanBn&width=320: Resolving domain and connecting to all available addresses
    V/Thumb Loader(29401): (48 ms) http://manager.thumbnails.simplestream.com/imagesizecacheurl.php?path=aHR0cDovL2kuZGlnaWd1aWRlLnR2L3VwLzEzMDgvODk3Njg1LUhvd3RvYmUtMTM3NjY0NjE5ODAuanBn&width=320: socket connected
    V/Thumb Loader(29401): (49 ms) http://manager.thumbnails.simplestream.com/imagesizecacheurl.php?path=aHR0cDovL2kuZGlnaWd1aWRlLnR2L3VwLzEzMDgvODk3Njg1LUhvd3RvYmUtMTM3NjY0NjE5ODAuanBn&width=320: 
    V/Thumb Loader(29401): GET /imagesizecacheurl.php?path=aHR0cDovL2kuZGlnaWd1aWRlLnR2L3VwLzEzMDgvODk3Njg1LUhvd3RvYmUtMTM3NjY0NjE5ODAuanBn&width=320 HTTP/1.1
    V/Thumb Loader(29401): Host: manager.thumbnails.simplestream.com
    V/Thumb Loader(29401): User-Agent: Dalvik/1.6.0 (Linux; U; Android 4.3; GT-I9305 Build/JSS15J)
    V/Thumb Loader(29401): Accept-Encoding: gzip, deflate
    V/Thumb Loader(29401): Connection: keep-alive
    V/Thumb Loader(29401): Accept: */*
    V/Thumb Loader(29401): 
    V/Thumb Loader(29401): (50 ms) http://manager.thumbnails.simplestream.com/imagesizecacheurl.php?path=aHR0cDovL2kuZGlnaWd1aWRlLnR2L3VwLzEzMDgvODk3Njg1LUhvd3RvYmUtMTM3NjY0NjE5ODAuanBn&width=320: request completed
    V/Thumb Loader(29401): (81 ms) http://manager.thumbnails.simplestream.com/imagesizecacheurl.php?path=aHR0cDovL2kuZGlnaWd1aWRlLnR2L3VwLzEzMDgvODk3Njg1LUhvd3RvYmUtMTM3NjY0NjE5ODAuanBn&width=320: Received headers:
    V/Thumb Loader(29401): HTTP/1.1 200 OK
    V/Thumb Loader(29401): Server: nginx/1.2.1
    V/Thumb Loader(29401): Date: Tue, 15 Apr 2014 08:51:16 GMT
    V/Thumb Loader(29401): Content-Type: image/jpeg
    V/Thumb Loader(29401): Content-Length: 12442
    V/Thumb Loader(29401): Connection: keep-alive
    V/Thumb Loader(29401): X-Powered-By: PHP/5.4.6-1ubuntu1.3
    V/Thumb Loader(29401): ETag: "f859add9-52b42969"
    V/Thumb Loader(29401): Last-Modified: Fri, 20 Dec 2013 11:26:33 GMT
    V/Thumb Loader(29401): Cache-Control: private
    V/Thumb Loader(29401): 
    D/Thumb Loader(29401): (84 ms) http://manager.thumbnails.simplestream.com/imagesizecacheurl.php?path=aHR0cDovL2kuZGlnaWd1aWRlLnR2L3VwLzEzMDgvODk3Njg1LUhvd3RvYmUtMTM3NjY0NjE5ODAuanBn&width=320: Caching response
    V/Thumb Loader(29401): (85 ms) http://manager.thumbnails.simplestream.com/imagesizecacheurl.php?path=aHR0cDovL2kuZGlnaWd1aWRlLnR2L3VwLzEzMDgvODk3Njg1LUhvd3RvYmUtMTM3NjY0NjE5ODAuanBn&width=320: Final (post cache response) headers:
    V/Thumb Loader(29401): HTTP/1.1 200 OK
    V/Thumb Loader(29401): Server: nginx/1.2.1
    V/Thumb Loader(29401): Date: Tue, 15 Apr 2014 08:51:16 GMT
    V/Thumb Loader(29401): Content-Type: image/jpeg
    V/Thumb Loader(29401): Content-Length: 12442
    V/Thumb Loader(29401): Connection: keep-alive
    V/Thumb Loader(29401): X-Powered-By: PHP/5.4.6-1ubuntu1.3
    V/Thumb Loader(29401): ETag: "f859add9-52b42969"
    V/Thumb Loader(29401): Last-Modified: Fri, 20 Dec 2013 11:26:33 GMT
    V/Thumb Loader(29401): Cache-Control: private
    V/Thumb Loader(29401): 
    D/Thumb Loader(29401): (85 ms) http://manager.thumbnails.simplestream.com/imagesizecacheurl.php?path=aHR0cDovL2kuZGlnaWd1aWRlLnR2L3VwLzEzMDgvODk3Njg1LUhvd3RvYmUtMTM3NjY0NjE5ODAuanBn&width=320: Connection successful
    D/Thumb Loader(29401): (86 ms) http://manager.thumbnails.simplestream.com/imagesizecacheurl.php?path=aHR0cDovL2kuZGlnaWd1aWRlLnR2L3VwLzEzMDgvODk3Njg1LUhvd3RvYmUtMTM3NjY0NjE5ODAuanBn&width=320: context has died, cancelling
    
    

    I'm not sure why the context has died. This is within a ListView CursorAdapter.

    opened by iNdieboyjeff 30
  • Connection closed before response completed for SSL requests

    Connection closed before response completed for SSL requests

    I'm attempting to connect to make a GET request over SSL using the following code:

    Ion.with(getActivity())
          .load("https://api.clyp.it/featuredlist/popular")
          .asJsonArray();
    

    and I get the following error:

    06-18 00:16:50.075    4530-5072/it.clyp E/Clyp﹕ connection closed before response completed.
        com.koushikdutta.async.http.ConnectionClosedException: connection closed before response completed.
                at com.koushikdutta.async.http.AsyncHttpResponseImpl$3.onCompleted(AsyncHttpResponseImpl.java:95)
                at com.koushikdutta.async.AsyncNetworkSocket.reportEnd(AsyncNetworkSocket.java:256)
                at com.koushikdutta.async.AsyncNetworkSocket.reportEndPending(AsyncNetworkSocket.java:268)
                at com.koushikdutta.async.AsyncNetworkSocket.onReadable(AsyncNetworkSocket.java:185)
                at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:755)
                at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:600)
                at com.koushikdutta.async.AsyncServer.access$700(AsyncServer.java:37)
                at com.koushikdutta.async.AsyncServer$13.run(AsyncServer.java:549)
         Caused by: java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
                at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:545)
                at libcore.io.IoBridge.recvfrom(IoBridge.java:521)
                at java.nio.SocketChannelImpl.readImpl(SocketChannelImpl.java:327)
                at java.nio.SocketChannelImpl.read(SocketChannelImpl.java:289)
                at com.koushikdutta.async.SocketChannelWrapper.read(SocketChannelWrapper.java:24)
                at com.koushikdutta.async.AsyncNetworkSocket.onReadable(AsyncNetworkSocket.java:157)
                at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:755)
                at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:600)
                at com.koushikdutta.async.AsyncServer.access$700(AsyncServer.java:37)
                at com.koushikdutta.async.AsyncServer$13.run(AsyncServer.java:549)
         Caused by: libcore.io.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by peer)
                at libcore.io.Posix.recvfromBytes(Native Method)
                at libcore.io.Posix.recvfrom(Posix.java:136)
                at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:159)
                at libcore.io.IoBridge.recvfrom(IoBridge.java:518)
                at java.nio.SocketChannelImpl.readImpl(SocketChannelImpl.java:327)
                at java.nio.SocketChannelImpl.read(SocketChannelImpl.java:289)
                at com.koushikdutta.async.SocketChannelWrapper.read(SocketChannelWrapper.java:24)
                at com.koushikdutta.async.AsyncNetworkSocket.onReadable(AsyncNetworkSocket.java:157)
                at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:755)
                at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:600)
                at com.koushikdutta.async.AsyncServer.access$700(AsyncServer.java:37)
                at com.koushikdutta.async.AsyncServer$13.run(AsyncServer.java:549)
    

    If I attempt to make the same request using a regular HTTP request, it works fine:

    Ion.with(getActivity())
          .load("http://api.clyp.it/featuredlist/popular")
          .asJsonArray();
    

    The server has a valid, signed certificate and uses a TLS connection.

    Any idea what's causing the connection to close?

    opened by nathanjones 28
  • SSL load issue

    SSL load issue

    via @robUx4

    I am still having this issue with images loaded by Ion. I made a sample app with just Ion 1.4.1, Play Services 6.1 (and support v4) to test it with the following code :

    Ion.getDefault(this).getConscryptMiddleware().enable(true);
    
    Ion.with((ImageView) findViewById(R.id.imageView))
            .load("http://cdn2.vox-cdn.com/thumbor/KxtZNw37jKNfxdA0hX5edHvbTBE=/0x0:2039x1359/800x536/cdn0.vox-cdn.com/uploads/chorus_image/image/44254028/lg-g-watch.0.0.jpg");
    Ion.with((ImageView) findViewById(R.id.imageViewSSL))
            .load("https://cdn2.vox-cdn.com/thumbor/KxtZNw37jKNfxdA0hX5edHvbTBE=/0x0:2039x1359/800x536/cdn0.vox-cdn.com/uploads/chorus_image/image/44254028/lg-g-watch.0.0.jpg");
    

    On Genymotion 4.1 or Nexus 5 with 5.0 I can see the first image (non SSL) but not the SSL one.

    I get the following log:

    12-01 13:33:20.398    9769-9791/tests.proxy.gawst.org.testionsslv3 W/System.err? javax.net.ssl.SSLHandshakeException: Handshake failed
    12-01 13:33:20.398    9769-9791/tests.proxy.gawst.org.testionsslv3 W/System.err? at com.android.org.conscrypt.OpenSSLEngineImpl.unwrap(OpenSSLEngineImpl.java:436)
    12-01 13:33:20.398    9769-9791/tests.proxy.gawst.org.testionsslv3 W/System.err? at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:1006)
    12-01 13:33:20.398    9769-9791/tests.proxy.gawst.org.testionsslv3 W/System.err? at com.koushikdutta.async.AsyncSSLSocketWrapper$4.onDataAvailable(AsyncSSLSocketWrapper.java:172)
    12-01 13:33:20.398    9769-9791/tests.proxy.gawst.org.testionsslv3 W/System.err? at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:33)
    12-01 13:33:20.398    9769-9791/tests.proxy.gawst.org.testionsslv3 W/System.err? at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:61)
    12-01 13:33:20.398    9769-9791/tests.proxy.gawst.org.testionsslv3 W/System.err? at com.koushikdutta.async.Util.emitAllData(Util.java:20)
    12-01 13:33:20.398    9769-9791/tests.proxy.gawst.org.testionsslv3 W/System.err? at com.koushikdutta.async.AsyncNetworkSocket.onReadable(AsyncNetworkSocket.java:175)
    12-01 13:33:20.398    9769-9791/tests.proxy.gawst.org.testionsslv3 W/System.err? at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:788)
    12-01 13:33:20.398    9769-9791/tests.proxy.gawst.org.testionsslv3 W/System.err? at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:626)
    12-01 13:33:20.398    9769-9791/tests.proxy.gawst.org.testionsslv3 W/System.err? at com.koushikdutta.async.AsyncServer.access$700(AsyncServer.java:41)
    12-01 13:33:20.399    9769-9791/tests.proxy.gawst.org.testionsslv3 W/System.err? at com.koushikdutta.async.AsyncServer$13.run(AsyncServer.java:568)
    12-01 13:33:20.399    9769-9791/tests.proxy.gawst.org.testionsslv3 W/System.err? Caused by: javax.net.ssl.SSLProtocolException: SSL handshake terminated: ssl=0xa355b800: Failure in SSL library, usually a protocol error
    12-01 13:33:20.399    9769-9791/tests.proxy.gawst.org.testionsslv3 W/System.err? error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external/openssl/ssl/s23_clnt.c:765 0xac470e61:0x00000000)
    12-01 13:33:20.399    9769-9791/tests.proxy.gawst.org.testionsslv3 W/System.err? at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake_bio(Native Method)
    12-01 13:33:20.399    9769-9791/tests.proxy.gawst.org.testionsslv3 W/System.err? at com.android.org.conscrypt.OpenSSLEngineImpl.unwrap(OpenSSLEngineImpl.java:423)
    12-01 13:33:20.399    9769-9791/tests.proxy.gawst.org.testionsslv3 W/System.err? ... 10 more
    
    opened by koush 26
  • javax.net.ssl.SSLException: Fatal alert received protocol_version

    javax.net.ssl.SSLException: Fatal alert received protocol_version

    javax.net.ssl.SSLException: Fatal alert received protocol_version

    I cannot connect to server... I found connecting on Android 7.1.1 or earlier fails since January 2021, while the connection works on later versions. And It's because devices of Android operating systems prior to 7.1.1, don’t trust ISRG Root X1.

    read this: https://letsencrypt.org/2020/12/21/extending-android-compatibility.html

    opened by ali-salavati 0
  • System.err: error:10000065:SSL routines:OPENSSL_internal:ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT (external/boringssl/src/ssl/tls13_client.cc:337 0x7b6e4d005a:0x00000000)

    System.err: error:10000065:SSL routines:OPENSSL_internal:ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT (external/boringssl/src/ssl/tls13_client.cc:337 0x7b6e4d005a:0x00000000)

    javax.net.ssl.SSLHandshakeException: Read error: ssl=0xb400007c13df1b98: Failure in SSL library, usually a protocol error 2021-09-12 15:22:38.510 4996-5376/com.anwar.payment W/System.err: error:10000065:SSL routines:OPENSSL_internal:ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT (external/boringssl/src/ssl/tls13_client.cc:337 0x7b6e4d005a:0x00000000) 2021-09-12 15:22:38.510 4996-5376/com.anwar.payment W/System.err: at com.android.org.conscrypt.SSLUtils.toSSLHandshakeException(SSLUtils.java:362) 2021-09-12 15:22:38.510 4996-5376/com.anwar.payment W/System.err: at com.android.org.conscrypt.ConscryptEngine.convertException(ConscryptEngine.java:1134) 2021-09-12 15:22:38.510 4996-5376/com.anwar.payment W/System.err: at com.android.org.conscrypt.ConscryptEngine.unwrap(ConscryptEngine.java:919) 2021-09-12 15:22:38.510 4996-5376/com.anwar.payment W/System.err: at com.android.org.conscrypt.ConscryptEngine.unwrap(ConscryptEngine.java:747) 2021-09-12 15:22:38.510 4996-5376/com.anwar.payment W/System.err: at com.android.org.conscrypt.ConscryptEngine.unwrap(ConscryptEngine.java:712) 2021-09-12 15:22:38.510 4996-5376/com.anwar.payment W/System.err: at com.android.org.conscrypt.Java8EngineWrapper.unwrap(Java8EngineWrapper.java:237) 2021-09-12 15:22:38.510 4996-5376/com.anwar.payment W/System.err: at com.koushikdutta.async.AsyncSSLSocketWrapper$5.onDataAvailable(AsyncSSLSocketWrapper.java:194) 2021-09-12 15:22:38.510 4996-5376/com.anwar.payment W/System.err: at com.koushikdutta.async.Util.emitAllData(Util.java:23) 2021-09-12 15:22:38.510 4996-5376/com.anwar.payment W/System.err: at com.koushikdutta.async.AsyncNetworkSocket.onReadable(AsyncNetworkSocket.java:152) 2021-09-12 15:22:38.510 4996-5376/com.anwar.payment W/System.err: at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:821) 2021-09-12 15:22:38.510 4996-5376/com.anwar.payment W/System.err: at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:658) 2021-09-12 15:22:38.511 4996-5376/com.anwar.payment W/System.err: at com.koushikdutta.async.AsyncServer.access$800(AsyncServer.java:44) 2021-09-12 15:22:38.511 4996-5376/com.anwar.payment W/System.err: at com.koushikdutta.async.AsyncServer$14.run(AsyncServer.java:600) 2021-09-12 15:22:38.511 4996-5376/com.anwar.payment W/System.err: Caused by: javax.net.ssl.SSLProtocolException: Read error: ssl=0xb400007c13df1b98: Failure in SSL library, usually a protocol error 2021-09-12 15:22:38.511 4996-5376/com.anwar.payment W/System.err: error:10000065:SSL routines:OPENSSL_internal:ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT (external/boringssl/src/ssl/tls13_client.cc:337 0x7b6e4d005a:0x00000000) 2021-09-12 15:22:38.511 4996-5376/com.anwar.payment W/System.err: at com.android.org.conscrypt.NativeCrypto.ENGINE_SSL_read_direct(Native Method) 2021-09-12 15:22:38.511 4996-5376/com.anwar.payment W/System.err: at com.android.org.conscrypt.NativeSsl.readDirectByteBuffer(NativeSsl.java:568) 2021-09-12 15:22:38.511 4996-5376/com.anwar.payment W/System.err: at com.android.org.conscrypt.ConscryptEngine.readPlaintextDataDirect(ConscryptEngine.java:1095) 2021-09-12 15:22:38.511 4996-5376/com.anwar.payment W/System.err: at com.android.org.conscrypt.ConscryptEngine.readPlaintextDataHeap(ConscryptEngine.java:1115) 2021-09-12 15:22:38.511 4996-5376/com.anwar.payment W/System.err: at com.android.org.conscrypt.ConscryptEngine.readPlaintextData(ConscryptEngine.java:1087) 2021-09-12 15:22:38.511 4996-5376/com.anwar.payment W/System.err: at com.android.org.conscrypt.ConscryptEngine.unwrap(ConscryptEngine.java:876) 2021-09-12 15:22:38.511 4996-5376/com.anwar.payment W/System.err: ... 10 more

    opened by MohdAnwarAlam 0
  • setCallback return void

    setCallback return void

    On the latest version, setCallback method return void and I don't use any sample code on Java Android

    void setCallback(FutureCallback callback);

    eg.) on ProgressBarDownload.java

    Incompatible types error found return void, required com.koushikdutta.async.future.Future<File> Please help this.

    downloading = Ion.with(ProgressBarDownload.this) .load("http://developer.clockworkmod.com/downloads/51/4883/cm-10.1-20130512-CPUFREQ-m7.zip") .progressBar(progressBar) .progressHandler(new ProgressCallback() { @Override public void onProgress(long downloaded, long total) { downloadCount.setText("" + downloaded + " / " + total); } }) .write(getFileStreamPath("zip-" + System.currentTimeMillis() + ".zip")) .setCallback(new FutureCallback() { @Override public void onCompleted(Exception e, File result) { resetDownload(); if (e != null) { Toast.makeText(ProgressBarDownload.this, "Error downloading file", Toast.LENGTH_LONG).show(); return; } Toast.makeText(ProgressBarDownload.this, "File upload complete", Toast.LENGTH_LONG).show(); } });

    opened by kaleido8675 3
  • Event streaming - is there a way to implement or get the text at the

    Event streaming - is there a way to implement or get the text at the "ProgressCallback"?

    I need to leave the connection open and receive the updated text. This is playing chess on a website. They send activity on a stream. (I looked at with "curl" and it fires back json text for new moves.

    One thought I have is if the "progress callback could get the text in addition to the # of bytes downloaded.

    opened by actor10 0
  • How can I send Korean with the get String?

    How can I send Korean with the get String?

    in android,

    Ion.with(this) .load(url + user_name) .asString() .setCallback(new FutureCallback() { ... });

    in node.js,

    router.get('url/:user_name', function(req, res, next) { let user_name = req.params.user_name; console.log("print : ", user_name); });

    it works, but node can't read Korean characters "print : ì ±ì¤" <- The letters are broken

    How can I send Korean with the GET?

    opened by ghost 0
  • how to log the request body..?

    how to log the request body..?

    kindly tell us how to log the request body of the network call as we can get the response body in the setCallback method. how do we print out what request is being made and what user have sent to the server

    opened by vivekpanchal 0
Owner
Koushik Dutta
Koushik Dutta
🍂 Jetpack Compose image loading library which can fetch and display network images using Glide, Coil, and Fresco.

?? Jetpack Compose image loading library which can fetch and display network images using Glide, Coil, and Fresco.

Jaewoong Eum 1.4k Jan 2, 2023
An image loading and caching library for Android focused on smooth scrolling

Glide | View Glide's documentation | 简体中文文档 | Report an issue with Glide Glide is a fast and efficient open source media management and image loading

Bump Technologies 33.2k Jan 7, 2023
Image loading for Android backed by Kotlin Coroutines.

An image loading library for Android backed by Kotlin Coroutines. Coil is: Fast: Coil performs a number of optimizations including memory and disk cac

Coil 8.8k Jan 8, 2023
Powerful and flexible library for loading, caching and displaying images on Android.

Universal Image Loader The great ancestor of modern image-loading libraries :) UIL aims to provide a powerful, flexible and highly customizable instru

Sergey Tarasevich 16.8k Jan 8, 2023
A powerful image downloading and caching library for Android

Picasso A powerful image downloading and caching library for Android For more information please see the website Download Download the latest AAR from

Square 18.4k Jan 6, 2023
load-the-image Apply to compose-jb(desktop), Used to load network and local pictures.

load-the-image load-the-image Apply to compose-jb(desktop), Used to load network and local pictures. ?? Under construction It may change incompatibly

lt_taozi 13 Dec 29, 2022
An Android transformation library providing a variety of image transformations for Glide.

Glide Transformations An Android transformation library providing a variety of image transformations for Glide. Please feel free to use this. Are you

Daichi Furiya 9.7k Dec 30, 2022
An android image compression library.

Compressor Compressor is a lightweight and powerful android image compression library. Compressor will allow you to compress large photos into smaller

Zetra 6.7k Jan 9, 2023
An Android transformation library providing a variety of image transformations for Picasso

Picasso Transformations An Android transformation library providing a variety of image transformations for Picasso. Please feel free to use this. Are

Daichi Furiya 1.7k Jan 5, 2023
Image Picker for Android 🤖

Image Picker for Android ??

Esa Firman 1k Dec 31, 2022
Luban(鲁班)—Image compression with efficiency very close to WeChat Moments/可能是最接近微信朋友圈的图片压缩算法

Luban ?? English Documentation Luban(鲁班) —— Android图片压缩工具,仿微信朋友圈压缩策略。 Luban-turbo —— 鲁班项目的turbo版本,查看trubo分支。 写在前面 家境贫寒,工作繁忙。只能不定期更新,还望网友们见谅! 项目描述 目前做A

郑梓斌 13.1k Jan 7, 2023
ZoomableComposeImage - A zoomable image for jetpack compose

ZoomableComposeImage - A zoomable image for jetpack compose

RERERE 10 Dec 11, 2022
ComposeImageBlurhash is a Jetpack Compose component with the necessary implementation to display a blurred image

compose-image-blurhash ComposeImageBlurhash is a Jetpack Compose component with the necessary implementation to display a blurred image while the real

Orlando Novas Rodriguez 24 Nov 18, 2022
Easy to use, lightweight custom image view with rounded corners.

RoundedImageView Easy to use, lightweight custom image view with rounded corners. Explore the docs » View Demo · Report Bug · Request Feature About Th

Melik Mehmet Özyildirim 6 Dec 23, 2021
Compose Image library for Kotlin Multiplatform.

Compose ImageLoader Compose Image library for Kotlin Multiplatform. Setup Add the dependency in your common module's commonMain sourceSet kotlin {

Seiko 45 Dec 29, 2022
An Android library for managing images and the memory they use.

Fresco Fresco is a powerful system for displaying images in Android applications. Fresco takes care of image loading and display, so you don't have to

Facebook 16.9k Jan 8, 2023
A fast ImageView that supports rounded corners, ovals, and circles.

RoundedImageView A fast ImageView (and Drawable) that supports rounded corners (and ovals or circles) based on the original example from Romain Guy. I

Vince Mi 6.4k Jan 8, 2023
Adds touch functionality to Android ImageView.

TouchImageView for Android Capabilities TouchImageView extends ImageView and supports all of ImageView’s functionality. In addition, TouchImageView ad

Michael Ortiz 2.6k Jan 1, 2023
A circular ImageView for Android

CircleImageView A fast circular ImageView perfect for profile images. This is based on RoundedImageView from Vince Mi which itself is based on techniq

Henning Dodenhof 14.4k Jan 5, 2023