[macOS] TLS sessions are not supported on Native platform
RdeWilde opened this issue · comments
Running the macOS build leads to an error crashing the app on startup:
[macOS] TLS sessions are not supported on Native platform
Here is the stack:
2021-07-28 22:47:25.195389+0200 PeopleInSpace[1933:24712] Debug: (Kermit) startObservingPeopleUpdates
2021-07-28 22:47:25.207475+0200 PeopleInSpace[1933:24712] Calling IOPPFGetProperty thermally_optimized_maps!
2021-07-28 22:47:25.269994+0200 PeopleInSpace[1933:24712] It's not legal to call -layoutSubtreeIfNeeded on a view which is already being laid out. If you are implementing the view's -layout method, you can call -[super layout] instead. Break on void _NSDetectedLayoutRecursion(void) to debug. This will be logged only once. This may break in the future.
2021-07-28 22:47:25.310240+0200 PeopleInSpace[1933:24712] Debug: (Kermit) fetchAndStorePeople
Uncaught Kotlin exception: kotlinx.coroutines.CoroutinesInternalError: Fatal exception in coroutines machinery for AwaitContinuation(Shareable[used]){Completed}@213f938. Please read KDoc to 'handleFatalException' method and report this incident to maintainers
at 0 PeopleInSpace 0x00000001000e138e kfun:kotlin.Error#<init>(kotlin.String?;kotlin.Throwable?){} + 126
at 1 PeopleInSpace 0x00000001003d91de kfun:kotlinx.coroutines.CoroutinesInternalError#<init>(kotlin.String;kotlin.Throwable){} + 126
at 2 PeopleInSpace 0x0000000100434af7 kfun:kotlinx.coroutines.DispatchedTask#handleFatalException(kotlin.Throwable?;kotlin.Throwable?){} + 887
at 3 PeopleInSpace 0x0000000100434720 kfun:kotlinx.coroutines.DispatchedTask#run(){} + 3488
at 4 PeopleInSpace 0x000000010047158a kfun:kotlinx.coroutines.DarwinMainDispatcher.dispatch$lambda-0#internal + 90
at 5 PeopleInSpace 0x00000001004718a0 kfun:kotlinx.coroutines.DarwinMainDispatcher.$dispatch$lambda-0$FUNCTION_REFERENCE$43.invoke#internal + 64
at 6 PeopleInSpace 0x00000001004719b0 kfun:kotlinx.coroutines.DarwinMainDispatcher.$dispatch$lambda-0$FUNCTION_REFERENCE$43.$<bridge-UNN>invoke(){}#internal + 64
at 7 PeopleInSpace 0x0000000100472ad9 _6f72672e6a6574627261696e732e6b6f746c696e783a6b6f746c696e782d636f726f7574696e65732d636f7265_knbridge8 + 185
at 8 libdispatch.dylib 0x000000010149b844 _dispatch_call_block_and_release + 12
at 9 libdispatch.dylib 0x000000010149c826 _dispatch_client_callout + 8
at 10 libdispatch.dylib 0x00000001014ac446 _dispatch_main_queue_callback_4CF + 1100
at 11 CoreFoundation 0x00007fff37d73513 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
at 12 CoreFoundation 0x00007fff37d3318a __CFRunLoopRun + 2042
at 13 CoreFoundation 0x00007fff37d32333 CFRunLoopRunSpecific + 466
at 14 HIToolbox 0x00007fff3694dabd RunCurrentEventLoopInMode + 292
at 15 HIToolbox 0x00007fff3694d7d5 ReceiveNextEventCommon + 584
at 16 HIToolbox 0x00007fff3694d579 _BlockUntilNextEventMatchingListInModeWithFilter + 64
at 17 AppKit 0x00007fff34f94739 _DPSNextEvent + 883
at 18 AppKit 0x00007fff34f92f80 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1352
at 19 AppKit 0x00007fff34f84c8e -[NSApplication run] + 658
at 20 AppKit 0x00007fff34f56a76 NSApplicationMain + 777
at 21 PeopleInSpace 0x000000010000a14d main + 13
at 22 libdyld.dylib 0x00007fff71ef0cc9 start + 1
Caused by: kotlin.IllegalStateException: TLS sessions are not supported on Native platform.
at 0 PeopleInSpace 0x00000001000e8bbf kfun:kotlin.Throwable#<init>(kotlin.String?){} + 95
at 1 PeopleInSpace 0x00000001000e14bd kfun:kotlin.Exception#<init>(kotlin.String?){} + 93
at 2 PeopleInSpace 0x00000001000e172d kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 93
at 3 PeopleInSpace 0x00000001000e1ddd kfun:kotlin.IllegalStateException#<init>(kotlin.String?){} + 93
at 4 PeopleInSpace 0x0000000100764e7e kfun:io.ktor.network.tls#openTLSSession(io.ktor.network.sockets.Socket;io.ktor.utils.io.ByteReadChannel;io.ktor.utils.io.ByteWriteChannel;io.ktor.network.tls.TLSConfig;kotlin.coroutines.CoroutineContext){}io.ktor.network.sockets.Socket + 254
at 5 PeopleInSpace 0x000000010075f95c kfun:io.ktor.network.tls.$tlsCOROUTINE$0#invokeSuspend(kotlin.Result<kotlin.Any?>){}kotlin.Any? + 844
at 6 PeopleInSpace 0x000000010075fe8c kfun:io.ktor.network.tls#tls__at__io.ktor.network.sockets.Connection(kotlin.coroutines.CoroutineContext;io.ktor.network.tls.TLSConfig){}io.ktor.network.sockets.Socket + 460
at 7 PeopleInSpace 0x0000000100760192 kfun:io.ktor.network.tls#tls__at__io.ktor.network.sockets.Connection(kotlin.coroutines.CoroutineContext;kotlin.Function1<io.ktor.network.tls.TLSConfigBuilder,kotlin.Unit>){}io.ktor.network.sockets.Socket + 626
at 8 PeopleInSpace 0x0000000100774e96 kfun:io.ktor.client.engine.cio.Endpoint.$connectCOROUTINE$9.invokeSuspend#internal + 5974
at 9 PeopleInSpace 0x000000010077613f kfun:io.ktor.client.engine.cio.Endpoint.connect#internal + 383
at 10 PeopleInSpace 0x000000010077995f kfun:io.ktor.client.engine.cio.Endpoint.$makeDedicatedRequest$lambda-3COROUTINE$12.invokeSuspend#internal + 2847
at 11 PeopleInSpace 0x000000010010c274 kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 788
at 12 PeopleInSpace 0x00000001004344b7 kfun:kotlinx.coroutines.DispatchedTask#run(){} + 2871
at 13 PeopleInSpace 0x000000010047158a kfun:kotlinx.coroutines.DarwinMainDispatcher.dispatch$lambda-0#internal + 90
at 14 PeopleInSpace 0x00000001004718a0 kfun:kotlinx.coroutines.DarwinMainDispatcher.$dispatch$lambda-0$FUNCTION_REFERENCE$43.invoke#internal + 64
at 15 PeopleInSpace 0x00000001004719b0 kfun:kotlinx.coroutines.DarwinMainDispatcher.$dispatch$lambda-0$FUNCTION_REFERENCE$43.$<bridge-UNN>invoke(){}#internal + 64
at 16 PeopleInSpace 0x0000000100472ad9 _6f72672e6a6574627261696e732e6b6f746c696e783a6b6f746c696e782d636f726f7574696e65732d636f7265_knbridge8 + 185
at 17 libdispatch.dylib 0x000000010149b844 _dispatch_call_block_and_release + 12
at 18 libdispatch.dylib 0x000000010149c826 _dispatch_client_callout + 8
at 19 libdispatch.dylib 0x00000001014ac446 _dispatch_main_queue_callback_4CF + 1100
at 20 CoreFoundation 0x00007fff37d73513 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
at 21 CoreFoundation 0x00007fff37d3318a __CFRunLoopRun + 2042
at 22 CoreFoundation 0x00007fff37d32333 CFRunLoopRunSpecific + 466
at 23 HIToolbox 0x00007fff3694dabd RunCurrentEventLoopInMode + 292
at 24 HIToolbox 0x00007fff3694d7d5 ReceiveNextEventCommon + 584
at 25 HIToolbox 0x00007fff3694d579 _BlockUntilNextEventMatchingListInModeWithFilter + 64
at 26 AppKit 0x00007fff34f94739 _DPSNextEvent + 883
at 27 AppKit 0x00007fff34f92f80 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1352
at 28 AppKit 0x00007fff34f84c8e -[NSApplication run] + 658
at 29 AppKit 0x00007fff34f56a76 NSApplicationMain + 777
Printing description of exception:
(void *) exception = 0x00000001007ac6e0
(lldb)
I could find this resource, but not sure if it is relevant: https://youtrack.jetbrains.com/issue/KTOR-1071
Changing this line from https to http seems to "resolve" the problem, although this is not the right fix for the problem :-)
Hmm, I recently changed to that url to (1) proxy to my own server so I could return additional data and (2) to actually provide an https endpoint which was needed for GH pages web deployment....and looks like I didn't test macOS client after doing that!
Ok, I think this is limitation with CIO
ktor engine I had been using for macOS....just switched to curl
one (as now seems to be recommended at https://ktor.io/docs/http-client-engines.html#desktop and seems to work now....just pushed associated changes), @RdeWilde can you pull down latest and try it out again?
Ok, I think this is limitation with
CIO
ktor engine I had been using for macOS....just switched tocurl
one (as now seems to be recommended at https://ktor.io/docs/http-client-engines.html#desktop and seems to work now....just pushed associated changes), @RdeWilde can you pull down latest and try it out again?
I have to figure out how to test it. I used your repo thru 'use as template'-function, which is not ideal for pulling etc ;-)
I think your solution is right, but I didn't get it to work yet, but think this is due my own setup. It is around midnight now, so I'll try later tomorrow. Wish I had more time to spent :-)
Should I manually add it to xcode somehow, or should I literally just added the text file as in the commit?
Oh sweet, figured it out and it works now with HTTPS ✅ @joreilly
Just to help others: This "flaw" still exists in early 2023.
same issue by using CIO engine with native - failed with exception: kotlin.IllegalStateException: TLS sessions are not supported on Native platform.
And works with Curl engine.
If you want to use ktor with TLS enabled, I used io.ktor.client.engine.darwin
and it works like plug and play. I created an actual / expect function that creates a HttpClient
for each platform. :)
@tscholze that was my assumption too – and it looks like the best solution… especially if you also wish to build a JVM executable alongside native binaries. Thanks 👍
@milosmns you are welcome! I hope really that there will be a more convient solution in the future <3
@milosmns Instead of moving whole HttpClient
to expect/actual
, you can move HttpClientEngine
to expect/actual
and parse it to the HttpClient
in your shared module
. it would be cleaner and client configuration will be in a single place.
@7kashif. did it work for you? I just tried to use expect/actual
but the type of Curl
engine is HttpClientEngineFactory<CurlClientEngineConfig>
not HttpClientEngine
and I can not use it in commonMain