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.

Creating HttpClient with Apache engineFactory doesn't work

See original GitHub issue

Ktor Version and Engine Used (client or server and name) version, client/server, additional ktor modules included ktor 1.2.2 kotlin 1.3.41

dependencies

compile "ch.qos.logback:logback-classic:$logback_version"
    compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.2"
    compile "com.google.appengine:appengine:$appengine_version"
    compile "com.google.cloud:google-cloud-logging-logback:$gce_logback_version"
    compile "io.ktor:ktor-auth:$ktor_version"
    compile "io.ktor:ktor-client-apache:$ktor_version"
    compile "io.ktor:ktor-client-auth-jvm:$ktor_version"
    compile "io.ktor:ktor-client-core-jvm:$ktor_version"
    compile "io.ktor:ktor-client-core:$ktor_version"
    compile "io.ktor:ktor-html-builder:$ktor_version"
    compile "io.ktor:ktor-jackson:$ktor_version"
    compile "io.ktor:ktor-locations-metadata:$ktor_version"
    compile "io.ktor:ktor-locations:$ktor_version"
    compile "io.ktor:ktor-server-core:$ktor_version"
    compile "io.ktor:ktor-server-netty:$ktor_version"
    compile "io.ktor:ktor-server-servlet:$ktor_version"
    compile "net.logstash.logback:logstash-logback-encoder:5.1"
    compile "org.jetbrains:kotlin-css-jvm:1.0.0-pre.31-kotlin-1.2.41"
    compile 'com.google.cloud:google-cloud-firestore:1.11.0'
    compile 'com.google.cloud:google-cloud-storage:1.38.0'
    compile 'org.koin:koin-ktor:2.0.1'
    testCompile "io.ktor:ktor-server-tests:$ktor_version"
    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

Intelij:

IntelliJ IDEA 2019.1.3 (Ultimate Edition)
Build #IU-191.7479.19, built on May 28, 2019
JRE: 1.8.0_202-release-1483-b58 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.14.1

Describe the bug When installin Authentication module I need to create an Apache client. Doing that by using the constructor with engineFactory causes a weird error where Inteliji syntax is almost error like colour (#C53A47). When hovering over - no explanation, when I start the app it says that client lateinit var has never been initialized.

To Reproduce Follow official tutorial for adding authentication.

Expected behavior Adding http client by following factory object (Apache).

My workaround (1st line on the screenshot) is to use the constructor with engine (not engineFactory) and calling build() on Apache object.

Screenshots Screenshot 2019-07-17 at 20 54 53

Please accept my apologies if I posted this in a wrong place or this is obvious. It’s just my best intention to help others to avoid this behaviour.

Thanks

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

0reactions
e5lcommented, Apr 26, 2022

Can’t reproduce with Ktor 2.0.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Engines
To create the HTTP client with a specific engine, pass an engine class as an argument to the HttpClient constructor.
Read more >
Apache HttpClient not executing third request
I'm using Apache HttpClient to do a multipart request to upload a file, but it doesn't work after the third request. Here is...
Read more >
Apache HttpClient Example - CloseableHttpClient
Create instance of CloseableHttpClient using helper class HttpClients . Create HttpGet or HttpPost instance based on the HTTP request type. Use ...
Read more >
Apache HttpClient Connection Management
How to open, manage and close connections with the Apache HttpClient 4. ... We use it to create and manage a single connection...
Read more >
HttpClient Tutorial
Create an instance of one of the methods (GetMethod in this case). ... These classes are all found in the package org.apache.commons.httpclient.methods ....
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