question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ktor HttpClient (native/curl): json deserialization doesn't work when using a proxy

See original GitHub issue

Ktor Version and Engine Used (client or server and name)

plugins {
    id 'org.jetbrains.kotlin.multiplatform' version '1.3.61'
    id 'org.jetbrains.kotlin.plugin.serialization' version '1.3.61'
}

...

        commonMain {
            dependencies {
                implementation kotlin('stdlib-common')
                implementation "org.jetbrains.kotlinx:kotlinx-io:0.1.16"
                implementation "io.ktor:ktor-client-core:1.3.0-rc2"
                implementation "io.ktor:ktor-client-json:1.3.0-rc2"
                implementation "io.ktor:ktor-client-serialization:1.3.0-rc2"
                implementation("io.ktor:ktor-client-logging:1.3.0-rc2")
            }
        }

...

        macosMain {
            dependencies {
                implementation "org.jetbrains.kotlinx:kotlinx-io-native:0.1.16"
                implementation "io.ktor:ktor-client-serialization-native:1.3.0-rc2"
                implementation "io.ktor:ktor-client-json-native:1.3.0-rc2"
                implementation "io.ktor:ktor-client-curl:1.3.0-rc2"
                implementation("io.ktor:ktor-client-logging-native:1.3.0-rc2")
            }
        }

Describe the bug When using a proxy (

engine {
    proxy = ProxyBuilder.http(URLBuilder().apply {
        host = "localhost"
        port = 8888
    }.build())
}

), on the JVM, everything works fine.

But on native, serialization breaks, I get

Uncaught Kotlin exception: io.ktor.client.call.NoTransformationFoundException: No transformation found: class io.ktor.utils.io.ByteChannelNative -> class org.jraf.klibqonto.internal.api.model.organizations.ApiOrganizationEnvelope 

To Reproduce Steps to reproduce the behavior: Use Ktor HttpClient with json serialization on native (in my case, MacOS) and configure a proxy, and run it. The above exception is thrown.

Expected behavior Serialization should work with a proxy.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Stexxecommented, Aug 31, 2020

@BoD thank you, I’ve reproduced it. Please follow the new issue KTOR-955 I’ve created in Youtrack.

0reactions
e5lcommented, Apr 5, 2021

Fixed in 1.4.2

Read more comments on GitHub >

github_iconTop Results From Across the Web

Content negotiation and serialization | Ktor
Negotiating media types between the client and server. For this, it uses the Accept and Content-Type headers. Serializing/deserializing the ...
Read more >
Issue With Deserialization Json Array with Ktor - Stack Overflow
Given that I am trying to pull a JsonArray from the URL, I thought using List<PostResponse> would work to let kotlinx serialization know...
Read more >
CHANGELOG.md · Gitee 极速下载/Ktor - Gitee.com
Introduce DoubleReceive feature that makes it work. Server CORS support fixed and improved; Added initial kotlinx.serialization support for ...
Read more >
Client request invalid: 406 Not Acceptable : KTOR-357
It should deserialize the json response into an object. Without JSON feature, the request works fine and is producing the JSON as output....
Read more >
io.ktor:ktor-client-json: Versions | Openbase
Fix deserialization issue in client (Fix #1800). GitHub issue/pr links in IDEA Git log (#1806); Fix log channel is not closed for ByteArrayContent...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found