So I switched the Ktor Engine from CIO to Jetty in...
# ktor
s
So I switched the Ktor Engine from CIO to Jetty in order to use Http2 but now I get an Exception:
<http://javax.net|javax.net>.ssl.SSLHandshakeException: Received fatal alert: no_application_protocol
Is something missing in the config?
Copy code
val client = HttpClient(Jetty) {
    engine {
        sslContextFactory = SslContextFactory.Client()
        clientCacheSize = 12
        if (proxyUrl != null) {
            proxy = ProxyBuilder.http(proxyUrl)
        }
    }
}
client.get(url) {   // url has scheme https
    //setHeaders
    ...
}
a
Can you share the URL you're making request to?
s
sure, it's https://erp-ref.app.ti-dienste.de/VAUCertificate in that form (without the proper header) it should return a status 401 NOT AUTHORIZED but not a fatal alert.
a
As I can see, the server responds with HTTP/1.1 response when I execute the following command
curl -v --http2 --http2-prior-knowledge <https://erp-ref.app.ti-dienste.de/VAUCertificate>
.
How do you check that the server supports HTTP/2?
s
🤔
curl being able to send http2 and our client only able to send http1.1 was the only obvious difference we could see, that might explain why our ktor client takes 18s(!) while curl takes 100ms. or is there setup missing for https when using CIO as an engine?
Copy code
val client = HttpClient(CIO) {
    useDefaultTransformers = false
    engine {
        if (proxyUrl != null) {
            proxy = ProxyBuilder.http(proxyUrl)
        }
    }
}.also {
    // see bug ticket: <https://youtrack.jetbrains.com/issue/KTOR-5616/Ktor-always-adds-by-default-an-Accept-Charset-header>
    it.defaultTransformers()
}
Well, the config works flawlessly local on my machine, but fails in the docker container when deployed, so I guess the configuration is generally fine 🤷‍♂️
a
Your configuration looks fine.
👍 1