Hi folks, I understand that the CIO client engine ...
# ktor
a
Hi folks, I understand that the CIO client engine for KTor supports native platforms, however I get this error when I'm using it on iOS (with KMP):
Copy code
failed with exception: kotlin.IllegalStateException: TLS sessions are not supported on Native platform.
Internet searches aren't giving me a ton of good info. Does anyone know if CIO is fully supported or not for iOS?
Ah, I see the docs say 'It supports only HTTP/1.x for now.' so guessing that means quite literally, no https.
r
TLS doesn't care whether its HTTP/1.x or not -- TLS isn't even tied to HTTP as a protocol. So those docs are not meaningful for your error.
What version of ktor are you using? I thought that the CIO client engine did implement TLS.
I'd use the
Darwin
engine for iOS though. You can provide the engine via an expect/actual.
a
Thanks, I'm using
3.1.2
. I have got Darwin to work, but I'm asking out of curiosity as the docs mostly seem to indicate that it should work, and at this point early on in my project's adoption of KMP, I wanted to make sure I understood the options as to which engines could be used.
๐Ÿ‘ 1
r
(For non-JVM platforms)
a
Yeah, seems like it. I should probably file an issue to improve the docs here as I can't imagine many users of the engine are interested in non-TLS sessions in 2025 ๐Ÿ™‚
๐Ÿ˜ 1
r
Indeed
a
Thanks for the confirmation ๐Ÿ‘
r
Looking at one of my projects, the engine can be chosen automatically by dependencies. So in common main when you instantiate
HttpClient
you just don't specify the engine -- simply include the darwin engine in your
iosMain
source set and the CIO engine in the
androidMain
source set.
Assuming that is not already what you have done considering you already have it working ๐Ÿ™‚
a
Yeah, I did see that as a suggestion but opted for a more explicit declaration of the engine since it wasn't clear to me why it would be advantageous to make it less clear to anyone inspecting the code.
๐Ÿ‘ 1
s
Hi @Aidan, you can also consider using okhttp for android https://ktor.io/docs/client-engines.html#limitations
๐Ÿ‘ 1