Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError in AsyncSSLSocketWrapper #928

Open
cirediew opened this issue Jun 2, 2020 · 13 comments
Open

AssertionError in AsyncSSLSocketWrapper #928

cirediew opened this issue Jun 2, 2020 · 13 comments

Comments

@cirediew
Copy link

cirediew commented Jun 2, 2020

Hi!

I get the following error when running a Get using ion.

    java.lang.AssertionError
        at com.koushikdutta.async.AsyncSSLSocketWrapper.write(AsyncSSLSocketWrapper.java:474)
        at com.koushikdutta.async.AsyncSSLSocketWrapper.handleHandshakeStatus(AsyncSSLSocketWrapper.java:378)
        at com.koushikdutta.async.AsyncSSLSocketWrapper.handshake(AsyncSSLSocketWrapper.java:182)
        at com.koushikdutta.async.http.AsyncSSLSocketMiddleware.tryHandshake(AsyncSSLSocketMiddleware.java:89)
        at com.koushikdutta.async.http.AsyncSSLSocketMiddleware$2.onConnectCompleted(AsyncSSLSocketMiddleware.java:106)
        at com.koushikdutta.async.http.AsyncSocketMiddleware.lambda$getSocket$3$AsyncSocketMiddleware(AsyncSocketMiddleware.java:217)
        at com.koushikdutta.async.http.-$$Lambda$AsyncSocketMiddleware$glazjOxu-iNIRY4N890Wl1ngyGo.onCompleted(Unknown Source:12)
        at com.koushikdutta.async.future.SimpleFuture.lambda$setCallback$0(SimpleFuture.java:216)
        at com.koushikdutta.async.future.-$$Lambda$SimpleFuture$h_gK5Y1XHZI1H8JTE2xOg4dXbp8.onCompleted(Unknown Source:2)
        at com.koushikdutta.async.future.SimpleFuture$FutureCallsite.loop(SimpleFuture.java:130)
        at com.koushikdutta.async.future.SimpleFuture.handleCallbackUnlocked(SimpleFuture.java:153)
        at com.koushikdutta.async.future.SimpleFuture.setComplete(SimpleFuture.java:195)
        at com.koushikdutta.async.future.SimpleFuture.setComplete(SimpleFuture.java:175)
        at com.koushikdutta.async.future.-$$Lambda$VNAuWcttAhMr3VsWCERbmWE6yR0.success(Unknown Source:2)
        at com.koushikdutta.async.future.SimpleFuture.lambda$success$4(SimpleFuture.java:287)
        at com.koushikdutta.async.future.-$$Lambda$SimpleFuture$DxIsaj7NQi76eWgOKS4iviWPLV0.onCompleted(Unknown Source:4)
        at com.koushikdutta.async.future.SimpleFuture$FutureCallsite.loop(SimpleFuture.java:130)
        at com.koushikdutta.async.future.SimpleFuture.handleCallbackUnlocked(SimpleFuture.java:153)
        at com.koushikdutta.async.future.SimpleFuture.setComplete(SimpleFuture.java:195)
        at com.koushikdutta.async.future.SimpleFuture.setComplete(SimpleFuture.java:182)
        at com.koushikdutta.async.http.-$$Lambda$cBC5du-82c5EcL72rP5wNK7Y2Y4.onConnectCompleted(Unknown Source:2)
        at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:906)
        at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:727)
        at com.koushikdutta.async.AsyncServer.access$800(AsyncServer.java:46)
        at com.koushikdutta.async.AsyncServer$8.run(AsyncServer.java:681)

It occurs here: https://github.com/koush/AndroidAsync/blob/master/AndroidAsync/src/com/koushikdutta/async/AsyncSSLSocketWrapper.java#L474

I'm not sure why or if I'm doing something wrong but using the debugger bb.remaingin and writeList.hasRemaining() are always 0 for me and therefore an assertion error is thrown.

My code:

    public static <T> Future<Response<T>> GetConnect(Context context, String url, Class<T> type, String instance, String method, API api, FutureCallback<Response<T>> callback, boolean auth) {
        String csrf_session = AccountGeneral.getInstance(context).peekAuthToken();
        if (csrf_session == null && auth) {
            LOG.CONNECTION(instance, "GETCONNECT CSRF_SESSION IS EMPTY");
            if (callback != null)
                callback.onCompleted(new AuthenticationException("Authentication required"), null);
        } else {
            //Ion ion = Ion.getDefault(context);
            Ion ion = Ion.getInstance(context, instance);
            if (LOG.ION) {
                ion.configure().setLogging(instance, Log.VERBOSE);
                LOG.CONNECTION(ion.configure().userAgent());
            }
            try {
                ion.getCookieMiddleware().clear();
            } catch (NullPointerException ignore) {
            }
            Builders.Any.B loadBuilder = ion.build(context).load(method, url);
            if (auth) {
                if (api == API.V0) {
                    LOG.CONNECTION(instance, "CSRF+SESSION: " + csrf_session);
                    loadBuilder = buildHeaders(context, loadBuilder, csrf_session);
                } else {
                    loadBuilder = buildHeadersNew(context, loadBuilder);
                }
            }
            Future<Response<T>> responseFuture = loadBuilder
                    .noCache()
                    //.proxy("192.168.109.35",8888)
                    .setTimeout(5000)
                    .followRedirect(false)
                    .as(type)
                    .withResponse();
            responseFuture.setCallback(callback);
            return responseFuture;
        }
        return null;
    }

When I'm running release mode everything seems to be working fine. So why is it not in debug mode?

Any help is appreciated!

@Shvet
Copy link

Shvet commented Aug 5, 2020

getting same error!! anyone found solution?

@Shvet
Copy link

Shvet commented Aug 5, 2020

Ion.with(context)
                .load("GET", url)
                .setTimeout(60000)
                .addHeader("device-type", "android")
                .asJsonObject().withResponse()
                .setCallback((e, result) -> {
                    Log.e("Exception", e.toString());
                    if (result != null) {
                        JsonObject object = result.getResult();
                        Log.e("Object", object.getAsString());
                    }
                });

This is what i have used

@djdance
Copy link

djdance commented Aug 21, 2020

Same crash! In my case I decided to test old working app on Android 5.1
UPD on any android

@djdance
Copy link

djdance commented Aug 21, 2020

I've found the solution.

in top gradle remove this
'com.android.tools.build:gradle:4.1.0-rc01

and set this
'com.android.tools.build:gradle:4.0.1'

@Shvet
Copy link

Shvet commented Sep 15, 2020

Worked By changing Gradle to 4.0.1

@shaithana
Copy link

This happens again in Gradle 4.1.0

@tomeroto
Copy link

I have same issues, after update my Android Studio to 4.1.

10-14 20:00:29.799 5110-5151/com.test.http E/AndroidRuntime: FATAL EXCEPTION: ion-ion
    Process: com.test.http, PID: 5110
    java.lang.AssertionError
        at com.koushikdutta.async.AsyncSSLSocketWrapper.write(AsyncSSLSocketWrapper.java:492)
        at com.koushikdutta.async.AsyncSSLSocketWrapper.handleHandshakeStatus(AsyncSSLSocketWrapper.java:378)
        at com.koushikdutta.async.AsyncSSLSocketWrapper.handshake(AsyncSSLSocketWrapper.java:182)
        at com.koushikdutta.async.http.AsyncSSLSocketMiddleware.tryHandshake(AsyncSSLSocketMiddleware.java:89)
        at com.koushikdutta.async.http.AsyncSSLSocketMiddleware$2.onConnectCompleted(AsyncSSLSocketMiddleware.java:106)
        at com.koushikdutta.async.http.AsyncSocketMiddleware.lambda$getSocket$3$AsyncSocketMiddleware(AsyncSocketMiddleware.java:217)
        at com.koushikdutta.async.http.-$$Lambda$AsyncSocketMiddleware$glazjOxu-iNIRY4N890Wl1ngyGo.onCompleted(lambda)
        at com.koushikdutta.async.future.SimpleFuture.lambda$setCallback$0(SimpleFuture.java:212)
        at com.koushikdutta.async.future.-$$Lambda$SimpleFuture$h_gK5Y1XHZI1H8JTE2xOg4dXbp8.onCompleted(lambda)
        at com.koushikdutta.async.future.SimpleFuture$FutureCallsite.loop(SimpleFuture.java:130)
        at com.koushikdutta.async.future.SimpleFuture.handleCallbackUnlocked(SimpleFuture.java:153)
        at com.koushikdutta.async.future.SimpleFuture.setComplete(SimpleFuture.java:191)
        at com.koushikdutta.async.future.SimpleFuture.setComplete(SimpleFuture.java:174)
        at com.koushikdutta.async.future.-$$Lambda$VNAuWcttAhMr3VsWCERbmWE6yR0.success(lambda)
        at com.koushikdutta.async.future.SimpleFuture.lambda$success$4(SimpleFuture.java:279)
        at com.koushikdutta.async.future.-$$Lambda$SimpleFuture$DxIsaj7NQi76eWgOKS4iviWPLV0.onCompleted(lambda)
        at com.koushikdutta.async.future.SimpleFuture$FutureCallsite.loop(SimpleFuture.java:130)
        at com.koushikdutta.async.future.SimpleFuture.handleCallbackUnlocked(SimpleFuture.java:153)
        at com.koushikdutta.async.future.SimpleFuture.setComplete(SimpleFuture.java:191)
        at com.koushikdutta.async.future.SimpleFuture.setComplete(SimpleFuture.java:178)
        at com.koushikdutta.async.http.-$$Lambda$cBC5du-82c5EcL72rP5wNK7Y2Y4.onConnectCompleted(lambda)
        at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:896)
        at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:717)
        at com.koushikdutta.async.AsyncServer.access$800(AsyncServer.java:46)
        at com.koushikdutta.async.AsyncServer$11.run(AsyncServer.java:671)
10-14 20:00:29.984 5110-5128/com.test.http E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f9a075e20

@islamarr
Copy link

The same error in Gradle 4.1.0, please Fix it

@rajabpour
Copy link

The same error in Gradle 4.1.1,
How to fix it???

@zwirne
Copy link

zwirne commented Feb 23, 2021

The same error with Gradle 4.1.2.

Thx to @djdance!!!
Set to 'com.android.tools.build:gradle:4.0.1' solved it

@thasneemp
Copy link

Hi when we can expect the fixes? koush

@islamarr
Copy link

islamarr commented May 24, 2021

Fixed in 3.1.0
implementation 'com.koushikdutta.ion:ion:3.1.0'

@islamarr
Copy link

The same error in Gradle 4.1.1,
How to fix it???

Fixed in version 3.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants