FunkyMuse
05/29/2022, 3:17 PMArjan van Wieringen
05/30/2022, 6:20 PMmode
to no-cors
for Ktor Client in JS.napperley
05/31/2022, 1:49 AMMuhammad Usman
05/31/2022, 11:44 AMtasks {
named<ShadowJar>("shadowJar") {
include("credentials/")
exclude("department_images/")
exclude("json/")
exclude("question_images/")
}
}
natario1
05/31/2022, 6:47 PMdefaultRequest { }
to configure the base URL for our backend, like https://backend.com , then do things like get("users")
.
If the base url has a segment though, like https://backend.com/v1 . v1 is ignored in get("users")
will still hit https://backend.com/users. I kind of get why this happens but is there any way to make it work?jeggy
05/31/2022, 9:10 PMbitkid
06/01/2022, 12:05 PMmartinm
06/02/2022, 7:45 AMwithContext
), that should be used when handling requests. (I want to create an active span with opentelemetry-extension-kotlin that is tied to the coroutine context). Looking through the examples I can only see before and after hooks, but nothing like an around interceptor. Any ideas?doyaaaaaaken
06/02/2022, 8:04 AMCachingHeader
plugin](https://ktor.io/docs/caching.html), and CachingOptions
(io.ktor.server.http.content) class shows compile errors because it became to need expires
parameter (non nullable).
As I know, If we want to return Cache-Control: no-cache
as http response, then expires
header is not required.
Why is this parameter required?bitkid
06/02/2022, 8:47 AM"{\r\n \"swagger\" : \"2.0\",\r\n \"info\" : {\r\n \"description\" : \"Talks to AD and handles permissions\",\r\n
Claude Brisson
06/02/2022, 9:33 AMRobert Jaros
06/02/2022, 5:00 PMjava.lang.NoSuchMethodError: io.ktor.client.request.HttpRequestKt.url$default(Lio/ktor/client/request/HttpRequestBuilder;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
when using Ktor client 2.0.1. What could be the problem?simon.vergauwen
06/02/2022, 7:07 PMApplicationEngine#stop
? Currently, I am seeing all open requests result in CancellationException
.
2022-06-02 20:52:27.779 [eventLoopGroupProxy-4-3] DEBUG ktor.application - 500 Internal Server Error: GET - /health. Exception class kotlinx.coroutines.JobCancellationException: LazyStandaloneCoroutine was cancelled
Trey
06/02/2022, 7:47 PMnapperley
06/02/2022, 10:47 PMOvsyannikov Alexey
06/03/2022, 10:47 AMsetBody
? I am using list and it throw an error with Exception in thread "main" kotlin.reflect.jvm.internal.KotlinReflectionInternalError: Function 'create$lambda-0' (JVM signature: create$lambda-0(Lio/ktor/client/request/HttpRequestBuilder;Ldev/inmo/micro_utils/repos/ktor/client/crud/KtorWriteStandardCrudRepoClient;Ljava/util/List;)V) not resolved in class dev.inmo.micro_utils.repos.ktor.client.crud.KtorWriteStandardCrudRepoClient: no members found
. I am using content negotiation and set up application json content typeBig Chungus
06/03/2022, 8:46 PMrrva
06/03/2022, 9:37 PMGiuliopime
06/03/2022, 9:47 PMSatyam Agarwal
06/04/2022, 9:26 AMSatyam Agarwal
06/04/2022, 9:29 AMktor-server-call-logging
https://github.com/ktorio/ktor/blob/main/ktor-server/ktor-server-plugins/ktor-server-call-logging/jvm/src/io/ktor/server/plugins/callloging/MDCProvider.kt#L12
Here mdc entries are registered in the plugin registry, but I couldn’t find out where they are extracted again back from the plugin registry to be used (they are however used from the pluginConfig, so I don’t see why these are being registered in pluginRegistry). Is this code redundant or is there any magic that I cant see 😅 ?Satyam Agarwal
06/04/2022, 12:09 PM[HttpClient] Pipeline used for executing [HttpRequest].
and
[HttpClient] Pipeline used for sending [HttpRequest] to remote server.
is still kind of vague for me.doyaaaaaaken
06/05/2022, 6:12 AMDatabase.connect()
) on the beginning of Ktor’s booting process (the first line of Application.module()
).
When I use Ktor v2, the testApplication
method creates a Ktor server application on each test method.
So, errors happens which says too many db clients
.
How do I solve it? Does anyone know this? 🙏Big Chungus
06/05/2022, 8:12 PMget("url")
closes the connection after the request is fulfilled).Viktor Orlyk
06/06/2022, 4:19 PMTucker Barbour
06/06/2022, 8:01 PM@Location("/") class index
@Location("/auth/{type?}") class login(val type: String = "")
@Location("/auth/{type}/callback") class callback(val type: String)
val loginProviders = listOf(
OAuthServerSettings.OAuth2ServerSettings(..),
OAuthServerSettings.OAuth2ServerSettings(..)
).associateBy { it.name }
fun Application.module() {
install(Authentication) {
oauth("oauth") {
providerLookup = {
loginProviders[application.locations.resolve<login>(login::class, this).type]
}
urlProvider = { p -> redirectUrl(callback(p.name), false) }
}
}
}
This is the gist with a bunch of other stuff left out. The key is begin able to map the url path to the name of the login provider. This ultimately allows a client to select which oauth provider to use. Any help or guidance would be appreciated.David Stibbe
06/06/2022, 9:19 PMtestApplication
test with 100 async calls by a client . However, it started locking up quite quickly and not even sending the remaining calls to the server.
At first I thought this problem must be in my service. But in the end it even happened if the service did nothing.
I solved it by configuring the CIO engine for the client
val client = createClient {
engine { CIO }
install(WebSockets)
}
(the websockets is there because I needed it..)
I was wondering: is this a known thing ? Or is there a different approach that would be preferred?Peter Hsu
06/06/2022, 10:37 PM#0 (null) in kfun:kotlinx.cinterop#<get-cstr>__at__kotlin.String(){}kotlinx.cinterop.CValues<kotlinx.cinterop.ByteVarOf<kotlin.Byte>> ()
#1 (null) in kfun:kotlinx.cinterop#<get-cstr>__at__kotlin.String(){}kotlinx.cinterop.CValues<kotlinx.cinterop.ByteVarOf<kotlin.Byte>> ()
#2 (null) in kfun:io.ktor.utils.io.charsets.CharsetImpl.<init>#internal ()
#3 (null) in kfun:io.ktor.utils.io.charsets.Charsets#<init>(){} ()
#4 (null) in InitSingletonStrict ()
#5 (null) in 0x106780000 ()
#6 (null) in Kotlin_initRuntimeIfNeeded ()
#7 (null) in (anonymous namespace)::workerRoutine(void*) ()
#8 (null) in _pthread_start ()
#9 (null) in thread_start ()
ribesg
06/07/2022, 8:22 AMMark Malik
06/07/2022, 3:57 PMjava.lang.UnsupportedOperationException: Headers can no longer be set because response was already completed
at io.ktor.server.netty.http1.NettyHttp1ApplicationResponse$headers$1.engineAppendHeader(NettyHttp1ApplicationResponse.kt:42)
at io.ktor.server.response.ResponseHeaders.append(ResponseHeaders.kt:57)
at io.ktor.server.response.ResponseHeaders.append$default(ResponseHeaders.kt:48)
at io.ktor.server.response.ApplicationResponsePropertiesKt.header(ApplicationResponseProperties.kt:14)
at io.ktor.server.plugins.cors.CORSKt.corsVary(CORS.kt:226)
This is the plugin code:
val HealthChecks: ApplicationPlugin<HealthConfig> = createApplicationPlugin("HealthChecks", ::HealthConfig) {
on(CallSetup) { call ->
if (call.request.path() != "/monitoring/health-check" && call.request.httpMethod != HttpMethod.Get) return@on
var healthCheckStatus: Map<String, Boolean>
runBlocking {
healthCheckStatus = pluginConfig.performChecks()
}
val statusCode = when (healthCheckStatus.all { it.value }) {
true -> HttpStatusCode.OK
false -> HttpStatusCode.InternalServerError
}
call.respondText(Json.encodeToString(healthCheckStatus), ContentType.Application.Json, statusCode)
}
}
I thought that I could use the plugin to expose request handlers not requiring to create a routing. Is there something invalid about this setup ?
FYI.
I have CORS enabled with anyHosts() option.
The error is thrown in
private fun ApplicationCall.corsVary() {
val vary = response.headers[HttpHeaders.Vary]
if (vary == null) {
response.header(HttpHeaders.Vary, HttpHeaders.Origin)
} else {
response.header(HttpHeaders.Vary, vary + ", " + HttpHeaders.Origin)
}
}
Mark Malik
06/07/2022, 3:57 PMjava.lang.UnsupportedOperationException: Headers can no longer be set because response was already completed
at io.ktor.server.netty.http1.NettyHttp1ApplicationResponse$headers$1.engineAppendHeader(NettyHttp1ApplicationResponse.kt:42)
at io.ktor.server.response.ResponseHeaders.append(ResponseHeaders.kt:57)
at io.ktor.server.response.ResponseHeaders.append$default(ResponseHeaders.kt:48)
at io.ktor.server.response.ApplicationResponsePropertiesKt.header(ApplicationResponseProperties.kt:14)
at io.ktor.server.plugins.cors.CORSKt.corsVary(CORS.kt:226)
This is the plugin code:
val HealthChecks: ApplicationPlugin<HealthConfig> = createApplicationPlugin("HealthChecks", ::HealthConfig) {
on(CallSetup) { call ->
if (call.request.path() != "/monitoring/health-check" && call.request.httpMethod != HttpMethod.Get) return@on
var healthCheckStatus: Map<String, Boolean>
runBlocking {
healthCheckStatus = pluginConfig.performChecks()
}
val statusCode = when (healthCheckStatus.all { it.value }) {
true -> HttpStatusCode.OK
false -> HttpStatusCode.InternalServerError
}
call.respondText(Json.encodeToString(healthCheckStatus), ContentType.Application.Json, statusCode)
}
}
I thought that I could use the plugin to expose request handlers not requiring to create a routing. Is there something invalid about this setup ?
FYI.
I have CORS enabled with anyHosts() option.
The error is thrown in
private fun ApplicationCall.corsVary() {
val vary = response.headers[HttpHeaders.Vary]
if (vary == null) {
response.header(HttpHeaders.Vary, HttpHeaders.Origin)
} else {
response.header(HttpHeaders.Vary, vary + ", " + HttpHeaders.Origin)
}
}
Rustam Siniukov
06/07/2022, 4:00 PM