Vladislav Areshkin [IceRock]
10/08/2021, 1:11 PMDoubleReceiveException
in ktor-client? Or maybe there are ways to create some kind of feautre/plugin that receives the body at the HttpReceivePipeline.After
phase, processes the body data and after continues piplene execution unchanged for the response? Is it possible?jdiaz
10/08/2021, 6:03 PMnilTheDev
10/09/2021, 5:02 PMSkovisen
10/09/2021, 7:58 PMrun
task with development mode set to true
and the build -t
task into a single gradle task?nilTheDev
10/10/2021, 3:53 AMhhariri
10/11/2021, 11:32 AMTim Malseed
10/12/2021, 7:39 AMFadiBouteraa
10/12/2021, 9:50 AMaltavir
10/12/2021, 1:37 PMmirland
10/12/2021, 7:14 PMAccess to fetch at '<https://myserver/api/v1/csrf>' from origin '<http://localhost:8080>' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I want to know if it's possible to use a reverse proxy in KotlinJs client. I tried to setup a proxy, in the engine setup, but it's not supported for JS.
Basically, I need to do something like this (this is how I solve my issue using react) . Do you know how can do something similar using ktor? Or do you know some alternative? Thanks!tim
10/13/2021, 9:32 AMSimran Preet Singh Narang
10/13/2021, 5:19 PMjean
10/14/2021, 7:05 AMprivate val jsonResponse = """
{
"offset": 0,
"limit": 20,
"available": 104,
"items": [
{
"type": "news type",
"title": "news title",
"image": "news image",
"link": "news link",
"date": "1621807201000"
}
]
}
""".trimIndent()
When I parse it manually with Json.decodeFromString<NewsList>(jsonResponse)
I get my NewsList
object without any issues, but when I run my unit test with a MockEngine
returning the json as a string for any request, I end up with the following error :
kotlinx.serialization.json.internal.JsonDecodingException: Expected start of the array '[', but had 'EOF' instead
JSON input: .....ink": "news link",
"date": "1621807201000"
}
]
}
What am I doing wrong here?John Pali
10/15/2021, 12:19 PMcall.receiveText()
but it gets is to a string - had a look on the docs about serialization, but got quite confused there.John Pali
10/15/2021, 8:56 PMSecurityContextHolder
in spring?Benoye
10/18/2021, 11:24 AMAuth
capability for JWT tokens on iOS and Android apps.
I encountered a case on iOS where I have two concurrent calls to my JWT-based API with no pre-existing token
Only one of both calls is retried after the requestToken()
and that call effectively succeeds, the other is not retried..
This is not critical but if anyone happens to know what is going on, I am interested 😉Stefan Oltmann
10/18/2021, 12:53 PMinvalid_grant
I guess I need to save the accessToken, correct?
Does someone have a demo how to do proper OAuth with Ktor?David Nault
10/18/2021, 6:23 PMStefan Oltmann
10/19/2021, 3:50 PMThis API is internal in ktor and should not be used. It could be removed or changed without notice.
warnings for this append
calls. 😕
https://github.com/ktorio/ktor-documentation/blob/0f2ef73cdc4fce483c2ee8e15c8995e6[…]nt-auth-oauth-google/src/main/kotlin/com/example/Application.ktarthur_sav
10/19/2021, 4:10 PMktor + docker
documentation which i found a bit incomplete.
In particular, the suggested Dockerfile is this
FROM openjdk:8-jdk
EXPOSE 8080:8080
RUN mkdir /app
COPY ./build/install/docker/ /app/
WORKDIR /app/bin
CMD ["./docker"]
However, ``./gradlew installDist`` has to be run manually before running docker which seems rather odd considering most use cases are deployment on the cloud.
So here is an improved version that just runs without additional steps (builds both the source & docker image)
FROM gradle:6-jdk8 AS build
COPY --chown=gradle:gradle . /home/gradle/src
WORKDIR /home/gradle/src
RUN gradle installDist --no-daemon
FROM openjdk:8-jdk
EXPOSE 8080:8080
RUN mkdir /app
COPY --from=build /home/gradle/src/build/install/docker/ /app/
WORKDIR /app/bin
CMD ["./docker"]
Also, naming the project docker
… could be confused with running docker itself.spierce7
10/19/2021, 8:22 PMembeddedServer(
factory = Netty,
port = 8080,
) {
modules()
}
But not
embeddedServer(
factory = Netty,
port = 8080,
module = Application::modules
)
Hexa
10/19/2021, 8:32 PMreturn@get
required here or can it can remove?
route("/test") {
get {
try {
// some logic
call.respond(HttpStatusCode.OK)
} catch (e: Exception) {
return@get call.respond(HttpStatusCode.InternalServerError) // here
}
}
Landry Norris
10/19/2021, 9:53 PMZhiqiang Bian
10/20/2021, 11:06 AMlogging
feature. Does anyone know how to match an HTTP request to the corresponding response in the logs?
Assuming I send 10 http requests to the backend immediately. And then, I should receive 10 responses. But I cannot tell which response belongs to which request from the logs. Is it possible to assign a UUID to each request and its corresponding responses, then we can match them in the logs easily?
Or it must involve some changes on the backend too? For example, the frontend generates a UUID in the header, and backend use the same one in the response header?
-----------------------------------------------------------
I assume that in the responsePipeline receives each response in the same order of the requestPipeline. But I am not sure if it is correct. So my temporal solution is to modify the Logging
class (since it does not allow extends). I added two Int variables requestSequenceId
and responseSequenceId
. Every time the logRequest
and logResponse
get called, I just plus 1 for each sequenceId.
private var requestSequenceId: Int = 0
private var responseSequenceId: Int = 0
...
private suspend fun logRequest(request: HttpRequestBuilder): OutgoingContent? {
if (<http://level.info|level.info>) {
logger.log("REQUEST SEQUENCE ID: ${requestSequenceId++}")
...
private fun logResponse(response: HttpResponse) {
if (<http://level.info|level.info>) {
logger.log("RESPONSE SEQUENCE ID: ${responseSequenceId++}")
Bert Heyman
10/21/2021, 9:39 AMVinay Pothnis
10/22/2021, 4:59 PMktor-client
and the best practices around it.
1. Whats the right way to re-use connections (or use a connection pool) with CIOEngine
? I am using the following configs:
engine {
maxConnectionsCount = 250
pipelining = true
endpoint {
maxConnectionsPerRoute = 100
pipelineMaxSize = 20
keepAliveTime = 5000
connectTimeout = 5000
connectAttempts = 5
threadsCount = 20
}
}
It looks like without the pipielining = true
flag, new connections were being created for every request/call.
Are these sufficient or is there any other config that I would need to set to effectively re-use connections?
2. Whats the recommended way to use client.close()
or client.use {}
- Especially when we are sharing/re-using the HttpClient
I went through the docs here - https://ktor.io/docs/client.html#close-client
With a shared HttpClient
- if I used client.use {}
- i was seeing errors on subsequent requests after some initial successful requests.
Errors like - kotlinx.coroutines.JobCancellationException: Parent job is Completed; job=JobImpl{Completed}@5e4f8454
So, when should this actually be used? During shutdown to release/cleanup the resources?
Thanks so much for your help with this!Charles Jo
10/22/2021, 6:17 PMCharles Jo
10/22/2021, 9:40 PMTobias Marschall
10/23/2021, 5:47 PMget("/test") {
launch {
// do something
}
call.respond("Success")
}
Warning Ambiguous coroutineContext due to CoroutineScope receiver of suspend function
when using:
suspend fun PipelineContext<Unit, ApplicationCall>.handleTest() {
launch {
// do something
}
call.respond("Success")
}
get("/test") {
handleTest()
}
How am i supposed to do this?Mustafa Ozhan
10/25/2021, 12:59 PMrequestQueueLimit
? The default is 16.
I started to have crashes in my clients Caused by java.net.ConnectException
and I believe only logical explanation is having so much call in the queue: https://stackoverflow.com/a/6876306/8334146Mustafa Ozhan
10/25/2021, 12:59 PMrequestQueueLimit
? The default is 16.
I started to have crashes in my clients Caused by java.net.ConnectException
and I believe only logical explanation is having so much call in the queue: https://stackoverflow.com/a/6876306/8334146spand
10/25/2021, 1:14 PMMustafa Ozhan
10/25/2021, 1:15 PMAleksei Tirman [JB]
10/25/2021, 5:53 PM