If someone encounter this exception in a multiplatform project using ktor 1.4.1 and getting the client in a lazy way
private val client by lazy {
HttpClient() {
[...]
I've found, and post it here for future reference, that this is due to a known bug: https://youtrack.jetbrains.com/issue/KTOR-1087
This could happen even if you have generated your client with the openapi-generator, but fortunally the exception in this case is managed and you could call it a second time ;)
UPDATE
The issue has been fixed with target release 2.0.0