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

NullPointerException: ssl_session == null #3301

Closed
ooblee opened this issue Apr 24, 2017 · 11 comments
Closed

NullPointerException: ssl_session == null #3301

ooblee opened this issue Apr 24, 2017 · 11 comments
Labels
needs info More information needed from reporter

Comments

@ooblee
Copy link

ooblee commented Apr 24, 2017

We met a bug recently. the trace log is

java.lang.NullPointerException: ssl_session == null
	at com.android.org.conscrypt.NativeCrypto.SSL_SESSION_cipher(Native Method)
	at com.android.org.conscrypt.OpenSSLSessionImpl.getCipherSuite(OpenSSLSessionImpl.java:320)
	at okhttp3.Handshake.get(Unknown Source)
	at okhttp3.internal.connection.RealConnection.connectTls(Unknown Source)
	at okhttp3.internal.connection.RealConnection.establishProtocol(Unknown Source)
	at okhttp3.internal.connection.RealConnection.buildConnection(Unknown Source)
	at okhttp3.internal.connection.RealConnection.connect(Unknown Source)
	at okhttp3.internal.connection.StreamAllocation.findConnection(Unknown Source)
	at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(Unknown Source)
	at okhttp3.internal.connection.StreamAllocation.newStream(Unknown Source)
	at okhttp3.internal.connection.ConnectInterceptor.intercept(Unknown Source)
	at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
	at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
	at okhttp3.internal.cache.CacheInterceptor.intercept(Unknown Source)
	at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
	at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
	at okhttp3.internal.http.BridgeInterceptor.intercept(Unknown Source)
	at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(Unknown Source)
	at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
	at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
	at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
	at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
	at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
	at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
	at okhttp3.RealCall.getResponseWithInterceptorChain(Unknown Source)
	at okhttp3.RealCall.access$100(Unknown Source)
	at okhttp3.RealCall$AsyncCall.execute(Unknown Source)
	at okhttp3.internal.NamedRunnable.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
	at java.lang.Thread.run(Thread.java:818)

What's more, the phone model is m5 and M611D,system version is Android 6.0 .
We think it is a rare problem when tls connect stage. It is great thing when you fixed it! Thanks ~

@xujinyang
Copy link

image
+1

@swankjesse
Copy link
Member

I don’t have enough information to take action on this. If you think there’s something OkHttp could do to fix this, please let me know what that is. If it’s something that the device’s vendor should deal with, please report to them.

@swankjesse swankjesse added the needs info More information needed from reporter label Apr 30, 2017
@ChengCheng-Hello
Copy link

+1 金立 M5,ROM: Meizu/FLYME,Android 6.0

@ronniesun
Copy link

the same issues appear com.squareup.okhttp3:okhttp:3.6.0 please check again @swankjesse

@swankjesse
Copy link
Member

@ronnie could you help us to isolate and reproduce?

@su1216
Copy link

su1216 commented Jun 8, 2017

+1 M5 android 6.0 okhttp 3.6.0

@hauler1
Copy link

hauler1 commented Jun 14, 2017

Is the problem solved?

@swankjesse
Copy link
Member

I think this needs to be fixed by the device maker.

@yschimke
Copy link
Collaborator

yschimke commented Dec 1, 2017

@swankjesse I think it's a Google Conscrypt bug. Happened on the conscrypt branch, I reported it and there is a fix that should make 1.0.

Happens when you try to use the Session after the remote side closes it. We may want to consider catching this NPE in okhttp, rethrowing as IOException.

https://github.com/google/conscrypt/pull/381/files

@autofocus
Copy link

autofocus commented Aug 6, 2018

i met same bug recently. @swankjesse said it is a Google Conscrypt bug, i follow @yschimke's guide,wrote a class NetExceptionHandlerInterceptor,then i add NetExceptionHandlerInterceptor to okhttpClient's NetworkInterceptor,so it handle all Exception and rethrowing as IOException,i think this method can resolve the problem.

public class NetExceptionHandlerInterceptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {
        try {
            return chain.proceed(chain.request());
        } catch (Exception e) {
            throw new IOException(e.getMessage());
        }
    }
}

//add  NetExceptionHandlerInterceptor to OkHttpClient.Builder.
 OkHttpClient.Builder builder = new OkHttpClient
                .Builder();
 builder.addNetworkInterceptor(new NetExceptionHandlerInterceptor());

@stan-ko
Copy link

stan-ko commented Aug 27, 2019

For my app its about 500 crashes per week and all of it happens only on Meizu M5 on Android 6. Suggested workaround based on NetExceptionHandlerInterceptor does not help. But if its really Google Conscrypt bug then probably it could be fixed using conscrypt lib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs info More information needed from reporter
Projects
None yet
Development

No branches or pull requests

10 participants