awslabs / aws-sdk-kotlin

Multiplatform AWS SDK for Kotlin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SSLHandshakeException on Android

ThinSnorlax opened this issue · comments

Describe the issue

Dear

I start to use kotlin develop my aws demo but I meet some error that I can't fixed;

The error:


E  FATAL EXCEPTION: DefaultDispatcher-worker-1
       Process: com.snx.kotlin, PID: 10484
       aws.smithy.kotlin.runtime.http.HttpException: javax.net.ssl.SSLHandshakeException: connection closed; HttpErrorCode(TLS_NEGOTIATION_ERROR)
         at aws.smithy.kotlin.runtime.http.engine.okhttp.OkHttpEngine.roundTrip(OkHttpEngine.kt:158)
         at aws.smithy.kotlin.runtime.http.engine.okhttp.OkHttpEngine$roundTrip$1.invokeSuspend(Unknown Source:15)
         at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
         at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
         at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
         at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
         at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
         at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
         Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@1d1fc09, Dispatchers.Default]
       Caused by: javax.net.ssl.SSLHandshakeException: connection closed
         at com.android.org.conscrypt.SSLUtils.toSSLHandshakeException(SSLUtils.java:363)
         at com.android.org.conscrypt.ConscryptEngineSocket.doHandshake(ConscryptEngineSocket.java:243)
         at com.android.org.conscrypt.ConscryptEngineSocket.startHandshake(ConscryptEngineSocket.java:220)
         at okhttp3.internal.connection.ConnectPlan.connectTls(ConnectPlan.kt:323)
         at okhttp3.internal.connection.ConnectPlan.connectTlsEtc(ConnectPlan.kt:188)
         at okhttp3.internal.connection.FastFallbackExchangeFinder.find(FastFallbackExchangeFinder.kt:78)
         at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:267)
         at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
         at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
         at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
         at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
         at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:84)
         at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
         at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:65)
         at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
         at aws.smithy.kotlin.runtime.http.engine.okhttp.MetricsInterceptor.intercept(MetricsInterceptor.kt:30)
         at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
         at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:205)
         at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:537)
         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
         at java.lang.Thread.run(Thread.java:1012)
       Caused by: java.io.EOFException: connection closed
         at com.android.org.conscrypt.ConscryptEngineSocket.doHandshake(ConscryptEngineSocket.java:243) 
         at com.android.org.conscrypt.ConscryptEngineSocket.startHandshake(ConscryptEngineSocket.java:220) 
         at okhttp3.internal.connection.ConnectPlan.connectTls(ConnectPlan.kt:323) 
         at okhttp3.internal.connection.ConnectPlan.connectTlsEtc(ConnectPlan.kt:188) 
         at okhttp3.internal.connection.FastFallbackExchangeFinder.find(FastFallbackExchangeFinder.kt:78) 
         at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:267) 
         at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32) 
         at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) 
         at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95) 
         at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) 
         at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:84) 
         at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) 
         at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:65) 
         at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) 
         at aws.smithy.kotlin.runtime.http.engine.okhttp.MetricsInterceptor.intercept(MetricsInterceptor.kt:30) 
         at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) 
         at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:205) 
         at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:537) 
         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137) 
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637) 
         at java.lang.Thread.run(Thread.java:1012) 
W  type=1400 audit(0.0:854286): avc: denied { search } for name="miuilog" dev="dm-39" ino=1877164 scontext=u:r:untrusted_app:s0:c183,c257,c512,c768 tcontext=u:object_r:data_log_file:s0 tclass=dir permissive=0
W  type=1400 audit(0.0:854287): avc: denied { search } for name="miuilog" dev="dm-39" ino=1877164 scontext=u:r:untrusted_app:s0:c183,c257,c512,c768 tcontext=u:object_r:data_log_file:s0 tclass=dir permissive=0
W  type=1400 audit(0.0:854288): avc: denied { search } for name="miuilog" dev="dm-39" ino=1877164 scontext=u:r:untrusted_app:s0:c183,c257,c512,c768 tcontext=u:object_r:data_log_file:s0 tclass=dir permissive=0
W  type=1400 audit(0.0:854289): avc: denied { search } for name="miuilog" dev="dm-39" ino=1877164 scontext=u:r:untrusted_app:s0:c183,c257,c512,c768 tcontext=u:object_r:data_log_file:s0 tclass=dir permissive=0
W  Failed to mkdir /data/miuilog/stability/memleak/heapdump/
D  onWindowFocusChanged hasWindowFocus false
I  Process is going to kill itself!
       java.lang.Exception
         at android.os.Process.killProcess(Process.java:1344)
         at com.android.internal.os.RuntimeInit$KillApplicationHandler.uncaughtException(RuntimeInit.java:181)
         at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1073)
         at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
         at kotlinx.coroutines.internal.CoroutineExceptionHandlerImplKt.propagateExceptionFinalResort(CoroutineExceptionHandlerImpl.kt:35)
         at kotlinx.coroutines.internal.CoroutineExceptionHandlerImpl_commonKt.handleUncaughtCoroutineException(CoroutineExceptionHandlerImpl.common.kt:52)
         at kotlinx.coroutines.CoroutineExceptionHandlerKt.handleCoroutineException(CoroutineExceptionHandler.kt:32)
         at kotlinx.coroutines.StandaloneCoroutine.handleJobException(Builders.common.kt:194)
         at kotlinx.coroutines.JobSupport.finalizeFinishingState(JobSupport.kt:231)
         at kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath(JobSupport.kt:910)
         at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.kt:867)
         at kotlinx.coroutines.JobSupport.makeCompletingOnce$kotlinx_coroutines_core(JobSupport.kt:832)
         at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:100)
         at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
         at kotlinx.coroutines.UndispatchedCoroutine.afterResume(CoroutineContext.kt:270)
         at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
         at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
         at kotlinx.coroutines.UndispatchedCoroutine.afterResume(CoroutineContext.kt:270)
         at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
         at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
         at kotlinx.coroutines.UndispatchedCoroutine.afterResume(CoroutineContext.kt:270)
         at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
         at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
         at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
         at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
         at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
         at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
         at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
I  Sending signal. PID: 10484 SIG: 9

gradle configure
implementation("aws.sdk.kotlin:lexruntimeservice-jvm:0.30.1-beta") implementation("aws.sdk.kotlin:lexmodelbuildingservice-jvm:0.30.1-beta")

Steps to Reproduce

This my code:

fun getLexStatusjava(botName: String) {
        val request = GetBotRequest {
            name = botName
            versionOrAlias = "\$LATEST"
        }

        val client = LexModelBuildingClient {
            region = "us-east-2"
            credentialsProvider = SnxCredentialsProvider()
        }

        GlobalScope.launch() {
            println("start request")
            val response = client.getBot(request)
            println("finish request")
            var status = response.status.toString()
            println("The status is $status")
        }
    }

I can reproduce every time when I run the code;

Current behavior

it can't run successfully
client.getBot(request)

AWS Kotlin SDK version used

0.30.1-beta

Platform (JVM/JS/Native)

JVM

Operating System and version

Android 13, MIUI14

@ThinSnorlax Thanks for taking the time to submit an issue. I have not been able to recreate this.

I do see that you are trying to create a LexModelBuildingClient with region of us-east-2. The Lex service is not available in that region. This could possibly be the source of the issue but probably not (locally I see an UnknownHostException for that region).

Could you try turning on additional logging (e.g. by configuring SLF4J logger with TRACE level and logMode = LogMode.LogRequest on the client)? It would be helpful to see what host endpoint you're attempting to actually connect to as well as any additional context that may come from trace logging.

Dear team

Thanks very much, and I had fixed this issue;
Region is a reason about this issue;
And other reason is DNS pollution;
Thank you again @aajtodd

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.