Closed AndreasVolkmann closed 1 year ago
The first issue is that it reports the missing feature that is not true. This is just wrong diagnostics. However, the root cause of your issue is that MDC captures too early so sessions are not yet configured for this call.
And even worse, we can't fix that easily because it's not clear what should be first. Let me explain the problem: what should happen if a session extraction is failed? Should error message be logged with MDC? How do we get MDC with no sessions?
@cy6erGn0m Thanks for the explanation. For me this functionality is not a must. Whatever the outcome, it should probably be reflected in the docs.
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
Ktor Version and Engine Used (client or server and name) 1.2.4, server, [cio, serialization, auth, locations, client-cio]
Describe the bug Just tried out the CallLogging MDC feature, but as soon as I try to get a value from sessions, my server becomes unresponsive. The call just takes forever and doesn't return. No log shows up. Then I tried the
CallId
feature with the same logic and this time it throws:io.ktor.application.MissingApplicationFeatureException: Application feature Sessions is not installed
.Once I switched to netty, it shows the same exception when using the
CallLogging
feature.To Reproduce Steps to reproduce the behavior:
fun main() { embeddedServer(CIO, 5000) { install(CallLogging) { mdc("test") { it.sessions.get()?.userId?.toString()
}
}
install(Sessions) {
cookie("oauthSampleSessionId") {
val secretSignKey = hex("000102030405060708090a0b0c0d0e0f")
transform(SessionTransportTransformerMessageAuthentication(secretSignKey))
}
}
install(Routing) {
get {
call.respond("Ok")
}
}
}.start(true)
}