Seb Jachec
10/27/2022, 3:03 PMSocketTimeoutException
, ConnectTimeoutException
) for our KMM Android app using Ktor client 2.1.2 and the OkHttp engine factory. Is it intentional that engine exceptions aren’t caught (have I misunderstood something 😅), or is this actually a Ktor bug?Christian Lippka
10/27/2022, 5:34 PMinstall(ContentNegotiation) {
json()
}
install(Pebble) {
loader(ClasspathLoader().apply {
prefix = "templates"
})
}
are executed in this order, going to /pebble-index gives me an exception on the backend
kotlinx.serialization.SerializationException: Serializer for class 'PebbleContent' is not found.
As soon as I change the order how those two blocks are called without changing anything else it works as expected.
Is there something I’m missing or not understanding or should a file an issue for this?
To reproduce you just have to download a template with those two plugins and in Application.kt
switch the order of
configureSerialization()
configureTemplating()
to toggle the error.
It looks like the order of those calls in Application.kt
depends on the order you added those plugins in the web ui.mserralta
10/28/2022, 6:55 AMAlex Styl
10/28/2022, 8:22 AMLeon Kiefer
10/28/2022, 2:19 PMStateFlow<HttpClient>
which returns/caches a client based on a Flow<HttpClientConfig>
so the client is update/a new client is created when the config is updated, but at the same time the old clients are cleaned up automatically, for example by the GC? In our use case we need to configure all our http clients dynamically during app runtime and the configuration is a Flow which can change at any time.trashcoder
10/28/2022, 5:01 PMDefaultRequest
plugin as described here:
https://ktor.io/docs/default-request.html#configure
i tried suppling the URL as complete string:
defaultRequest {
url("<https://ktor.io/docs/>")
}
and also tried setting the URL parameters by myself:
url {
protocol = URLProtocol.HTTPS
host = "<http://ktor.io|ktor.io>"
path("docs/")
}
the base URL i try to set is:
<https://api.ws.sonos.com/control/api/v1>
during debugging, the plugin shows the correct URL including all path segments. ✅
but the GET
request is executed without the path segments. ⛔
i receive this response (path is missing):
You don't have permission to access "http://api.ws.sonos.com/households" on this server.
for request:
httpClient.get("/households")
am i doing something wrong? is this a known issue?Eli
10/29/2022, 11:29 AMFudge
10/30/2022, 5:24 AMAustin Pederson
10/31/2022, 7:10 PMget() {...}
route from a plugin? If not, is there at least a way where I can get the parameters from a request inside a plugin?Partho Paul
11/01/2022, 3:56 PMrunningLimit
of my Netty engine but it didn’t help. Did anybody else ever came across this issue?
ktor version: 2.1.1IsaacMart
11/01/2022, 4:15 PMMalachi Holden
11/02/2022, 4:08 AMjava.net.ConnectException: Failed to connect to localhost/127.0.0.1:8080
I have a ktor server and an android app running on the same multiplatform project. Google doesn't say anything about the error except for this https://stackoverflow.com/questions/62500669/ktor-android-local-http-server-throws-error. I tried the solution and got nothingDirk
11/02/2022, 1:14 PMrocketraman
11/02/2022, 3:35 PMAustin Pederson
11/02/2022, 6:01 PMAustin Pederson
11/02/2022, 10:24 PMIsaacMart
11/03/2022, 9:52 AMMateu
11/03/2022, 11:16 AMKristian Nedrevold
11/05/2022, 1:43 PMAndrew O'Hara
11/05/2022, 10:05 PMLuiz Aguiar
11/07/2022, 2:22 PM-config
via command line the best approach?
java -jar sample-app.jar -config=anotherfile.conf
Sergey Aldoukhov
11/07/2022, 3:00 PMauthenticate("auth-oauth-google")
):
val userSession: UserSession = call.sessions.get() ?: return@get call.respondRedirect("/login")
But as a result of successful authentication, I redirect to one of my pages:
get("/auth/callback") {
val principal: OAuthAccessTokenResponse.OAuth2? = call.authentication.principal()
call.sessions.set(UserSession(principal?.accessToken.toString()))
call.respondRedirect("/status")
}
It worked fine when I had only one page under OAuth. But for multiple, how do I redirect to the one that invoked the OAuth flow? I’d like to avoid having a “landing” page that requires OAuth - my users most probably will use links/bookmarks to go to specific pages.leandro
11/07/2022, 7:50 PMNSURLSession
to ktor’s HttpClient
? something like
engine {
val config = NSURLSessionConfiguration.defaultSessionConfiguration()
val session = NSURLSession.sessionWithConfiguration(config)
usePreconfiguredSession(session)
}
It’s hard to debug the real issue but it basically does not work. The iOS app does not crash, but no network call is made.Cyril NB
11/07/2022, 10:01 PMMiroslav Sobotka
11/10/2022, 10:34 PMSam Gammon
11/10/2022, 11:37 PMSam Gammon
11/10/2022, 11:38 PMSam Gammon
11/10/2022, 11:38 PMxxfast
11/11/2022, 3:32 PMinstall(Logging) {
this.logger = get()
this.level = ALL
}
Louis Gautier
11/11/2022, 4:46 PMjava.lang.NoClassDefFoundError: Failed resolution of: Lio/ktor/client/engine/okhttp/OkHttp;
Caused by: java.lang.ClassNotFoundException: Didn't find class "io.ktor.client.engine.okhttp.OkHttp" on path: DexPathList[[dex file "/data/data/com.louis.androidappsample/code_cache/.overlay/base.apk/classes3.dex", dex file "/data/data/com.louis.androidappsample/code_cache/.overlay/base.apk/classes.dex", zip file "/data/app/~~j1M4G7GVnLQAYjWuRlSLCA==/com.louis.androidappsample-ETUEUYx9UiPhzUHXlOvm1Q==/base.apk"],nativeLibraryDirectories=[/data/app/~~j1M4G7GVnLQAYjWuRlSLCA==/com.louis.androidappsample-ETUEUYx9UiPhzUHXlOvm1Q==/lib/arm64, /system/lib64, /system_ext/lib64]]
I’ve tried everything. Clean and invalidate, remove all kind of caches, downgrade Ktor to 1.6.8, trying different engines..I don’t know how to solve that
My targets are configured like this :
android {
publishAllLibraryVariants()
}
jvm {
compilations.all {
kotlinOptions.jvmTarget = "11"
}
}
And sourceSet :
val commonMain by getting {
val commonMain by getting {
dependencies {
implementation(Ktor.Core)
implementation(Ktor.ContentNegotiation)
implementation(Ktor.Json)
implementation(Ktor.Logging)
implementation(Koin.Core)
}
}
}
val androidMain by getting {
dependencies {
implementation(Ktor.OkHttp)
implementation(Android.Material)
}
}
val jvmMain by getting {
dependencies {
implementation(Ktor.Apache)
}
}
Thanks !Louis Gautier
11/11/2022, 4:46 PMjava.lang.NoClassDefFoundError: Failed resolution of: Lio/ktor/client/engine/okhttp/OkHttp;
Caused by: java.lang.ClassNotFoundException: Didn't find class "io.ktor.client.engine.okhttp.OkHttp" on path: DexPathList[[dex file "/data/data/com.louis.androidappsample/code_cache/.overlay/base.apk/classes3.dex", dex file "/data/data/com.louis.androidappsample/code_cache/.overlay/base.apk/classes.dex", zip file "/data/app/~~j1M4G7GVnLQAYjWuRlSLCA==/com.louis.androidappsample-ETUEUYx9UiPhzUHXlOvm1Q==/base.apk"],nativeLibraryDirectories=[/data/app/~~j1M4G7GVnLQAYjWuRlSLCA==/com.louis.androidappsample-ETUEUYx9UiPhzUHXlOvm1Q==/lib/arm64, /system/lib64, /system_ext/lib64]]
I’ve tried everything. Clean and invalidate, remove all kind of caches, downgrade Ktor to 1.6.8, trying different engines..I don’t know how to solve that
My targets are configured like this :
android {
publishAllLibraryVariants()
}
jvm {
compilations.all {
kotlinOptions.jvmTarget = "11"
}
}
And sourceSet :
val commonMain by getting {
val commonMain by getting {
dependencies {
implementation(Ktor.Core)
implementation(Ktor.ContentNegotiation)
implementation(Ktor.Json)
implementation(Ktor.Logging)
implementation(Koin.Core)
}
}
}
val androidMain by getting {
dependencies {
implementation(Ktor.OkHttp)
implementation(Android.Material)
}
}
val jvmMain by getting {
dependencies {
implementation(Ktor.Apache)
}
}
Thanks !Aleksei Tirman [JB]
11/14/2022, 8:37 AMLouis Gautier
11/14/2022, 9:17 AMAleksei Tirman [JB]
11/14/2022, 10:03 AMLouis Gautier
11/14/2022, 11:50 AM