https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
ktor
  • c

    CLOVIS

    04/11/2020, 2:29 PM
    When using Ktor as a client, if I do 2 requests in two different Coroutines for the same client in parallel, are they executed in parallel or does the client force them to run sequentially? I'm asking because my stdout output looks very sequential (no mess because of lines being printed one inside the other), so I'm wondering.
    s
    • 2
    • 1
  • j

    Jamy

    04/14/2020, 12:16 PM
    Hello, any of you already deployed a ktor service with environment variables on Google App Engine from Google Cloud Platform? If possible without saving the variables in a file on git (security issue)
    j
    m
    • 3
    • 24
  • g

    gotoOla

    04/14/2020, 12:27 PM
    Hi! Does anyone know how Ktor is utilizing thread pools (call thread pool and worker thread pool) when working with Netty as its engine?
    s
    • 2
    • 1
  • s

    Sam Garfinkel

    04/15/2020, 3:52 PM
    Why can’t
    io.ktor.client.features.json.JsonSerializer.read(..)
    return the nullable
    Any?
    and why can’t the
    write
    function accept
    Any?
    ? Is this just how they were designed, or is there an actual implementation constraint?
    s
    • 2
    • 8
  • m

    Marek

    04/16/2020, 6:38 PM
    Hello everybody! 🙂 I'm qa engineer and I'm using one of sample ktor apps to practice new tool for performance testing using Locust. To training I'm using Kweet app https://github.com/ktorio/ktor-samples/tree/master/app/kweet I have a problem with database. I see it's h2 database stored in file. So I wrote a test script to create some users and kweets and I want to clear database after my tests. Could you guys help me with connection to DB? What I want to do is to execute some sql queries for example delete * from users, delete * from kweets. What's the address of h2 db and credentials in kweet app? We can assume that I'm running my python script from the main catalog of kweet app Maybe I should change some code to enable DB to be visible and connectable?
    • 1
    • 1
  • c

    christophsturm

    04/17/2020, 7:49 AM
    if I have jackson support installed, can i use it only for replies, but still set the post body of my request as normal string or byte array? also I have logging installed but it does not seem to log my outgoing requests and post bodies
    e
    s
    • 3
    • 14
  • m

    Maurice Wingbermuhle

    04/17/2020, 8:42 AM
    I\KtorHttpClient: REQUEST OBFUSCATED_URL failed with exception: kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen kotlinx.coroutines.InvokeOnCompletion@847c8
    I\KtorHttpClient: REQUEST OBFUSCATED_URL failed with exception: kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen io.ktor.util.pipeline.SuspendFunctionGun@596c8
    kotlinx.coroutines.CoroutinesInternalError: Fatal exception in coroutines machinery for DispatchedContinuation[DispatchQueue@1517388, Continuation @ $runAsync$lambda-1COROUTINE$200]. Please read KDoc to 'handleFatalException' method and report this incident to maintainers
            at 0   myLib                               0x00000001060ceb13 kfun:kotlin.Error.<init>(kotlin.String?;kotlin.Throwable?)kotlin.Error + 115 (/Users/teamcity1/teamcity_work/4d622a065c544371/runtime/src/main/kotlin/kotlin/Exceptions.kt:14:63)
            at 1   myLib                               0x0000000106629ad3 kfun:kotlinx.coroutines.CoroutinesInternalError.<init>(kotlin.String;kotlin.Throwable)kotlinx.coroutines.CoroutinesInternalError + 115 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/Exceptions.common.kt:28:77)
            at 2   myLib                               0x00000001067676ca kfun:kotlinx.coroutines.DispatchedTask.handleFatalException$kotlinx-coroutines-core(kotlin.Throwable?;kotlin.Throwable?) + 938 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/internal/DispatchedTask.kt:93:22)
            at 3   myLib                               0x00000001067672b4 kfun:kotlinx.coroutines.DispatchedTask.run() + 3156 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/internal/DispatchedTask.kt:64:13)
            at 4   myLib                               0x0000000105d93f35 kfun:ob.fus.client.utils.DispatchQueue.dispatch$lambda-0#internal + 85 (/Path-at-my-machine/myLib/src/iosMain/kotlin/ob/fus/client/utils/Dispatchers.kt:24:19)
            at 5   myLib                               0x0000000105d9401b kfun:io.hsdp.client.utils.DispatchQueue.$dispatch$lambda-0$FUNCTION_REFERENCE$492.invoke#internal + 59 (/Path-at-my-machine/myLib/src/iosMain/kotlin/ob/fus/client/utils/Dispatchers.kt:23:39)
            at 6   myLib                               0x0000000105d9407b kfun:io.hsdp.client.utils.DispatchQueue.$dispatch$lambda-0$FUNCTION_REFERENCE$492.$<bridge-UNN>invoke()#internal + 59 (/Path-at-my-machine/myLib/src/iosMain/kotlin/ob/fus/client/utils/Dispatchers.kt:23:39)
            at 7   myLib                               0x0000000105d94164 _687364702d636c69656e74_knbridge14 + 180 (/Path-at-my-machine/myLib/src/iosMain/kotlin/ob/fus/client/utils/Dispatchers.kt:23:39)
            at 8   libdispatch.dylib                   0x00000001042dfdd4 _dispatch_call_block_and_release + 12
            at 9   libdispatch.dylib                   0x00000001042e0d48 _dispatch_client_callout + 8
            at 10  libdispatch.dylib                   0x00000001042eede6 _dispatch_main_queue_callback_4CF + 1500
            at 11  CoreFoundation                      0x00007fff23bd4049 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
            at 12  CoreFoundation                      0x00007fff23bceca9 __CFRunLoopRun + 2329
            at 13  CoreFoundation                      0x00007fff23bce066 CFRunLoopRunSpecific + 438
            at 14  GraphicsServices                    0x00007fff384c0bb0 GSEventRunModal + 65
            at 15  UIKitCore                           0x00007fff48092d4d UIApplicationMain + 1621
            at 16  HSDP Client                         0x0000000103327f5b main + 75 (Path-at-my-machine/myContainingApp/AppDelegate.swift:7:7)
            at 17  libdyld.dylib                       0x00007fff5227ec25 start + 1
    Caused by: kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen io.hsdp.client.utils.$runAsync$lambda-1COROUTINE$200@36f9c78
            at 0   myLib                               0x00000001060dbec7 kfun:kotlin.Throwable.<init>(kotlin.String?)kotlin.Throwable + 87 (/Users/teamcity1/teamcity_work/4d622a065c544371/runtime/src/main/kotlin/kotlin/Throwable.kt:22:37)
            at 1   myLib                               0x00000001060cec95 kfun:kotlin.Exception.<init>(kotlin.String?)kotlin.Exception + 85 (/Users/teamcity1/teamcity_work/4d622a065c544371/runtime/src/main/kotlin/kotlin/Exceptions.kt:23:44)
            at 2   myLib                               0x00000001060ceeb5 kfun:kotlin.RuntimeException.<init>(kotlin.String?)kotlin.RuntimeException + 85 (/Users/teamcity1/teamcity_work/4d622a065c544371/runtime/src/main/kotlin/kotlin/Exceptions.kt:34:44)
            at 3   myLib                               0x0000000106123a45 kfun:kotlin.native.concurrent.InvalidMutabilityException.<init>(kotlin.String)kotlin.native.concurrent.InvalidMutabilityException + 85 (/Users/teamcity1/teamcity_work/4d622a065c544371/runtime/src/main/kotlin/kotlin/native/concurrent/Freezing.kt:22:60)
            at 4   myLib                               0x0000000106126bc8 ThrowInvalidMutabilityException + 680 (/Users/teamcity1/teamcity_work/4d622a065c544371/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt:90:11)
            at 5   myLib                               0x0000000106518ea8 MutationCheck + 104
            at 6   myLib                               0x00000001061093f0 kfun:kotlin.coroutines.native.internal.ContinuationImpl.<set-intercepted>#internal + 96 (/Users/teamcity1/teamcity_work/4d622a065c544371/runtime/src/main/kotlin/kotlin/coroutines/ContinuationImpl.kt:98:13)
            at 7   myLib                               0x00000001061099fc kfun:kotlin.coroutines.native.internal.ContinuationImpl.releaseIntercepted() + 428 (/Users/teamcity1/teamcity_work/4d622a065c544371/runtime/src/main/kotlin/kotlin/coroutines/ContinuationImpl.kt:110:9)
            at 8   myLib                               0x0000000106108415 kfun:kotlin.coroutines.native.internal.BaseContinuationImpl.resumeWith(kotlin.Result<kotlin.Any?>) + 1253 (/Users/teamcity1/teamcity_work/4d622a065c544371/runtime/src/main/kotlin/kotlin/coroutines/ContinuationImpl.kt:36:17)
            at 9   myLib                               0x0000000106767073 kfun:kotlinx.coroutines.DispatchedTask.run() + 2579 (/Users/teamcity1/teamcity_work/4d622a065c544371/backend.native/build/stdlib/kotlin/coroutines/Continuation.kt:44:5)
            at 10  myLib                               0x0000000105d93f35 kfun:io.hsdp.client.utils.DispatchQueue.dispatch$lambda-0#internal + 85 (/Path-at-my-machine/myLib/src/iosMain/kotlin/ob/fus/client/utils/Dispatchers.kt:24:19)
            at 11  myLib                               0x0000000105d9401b kfun:io.hsdp.client.utils.DispatchQueue.$dispatch$lambda-0$FUNCTION_REFERENCE$492.invoke#internal + 59 (/Path-at-my-machine/myLib/src/iosMain/kotlin/ob/fus/client/utils/Dispatchers.kt:23:39)
            at 12  myLib                               0x0000000105d9407b kfun:io.hsdp.client.utils.DispatchQueue.$dispatch$lambda-0$FUNCTION_REFERENCE$492.$<bridge-UNN>invoke()#internal + 59 (/Path-at-my-machine/myLib/src/iosMain/kotlin/ob/fus/client/utils/Dispatchers.kt:23:39)
            at 13  myLib                               0x0000000105d94164 _687364702d636c69656e74_knbridge14 + 180 (/Path-at-my-machine/myLib/src/iosMain/kotlin/ob/fus/client/utils/Dispatchers.kt:23:39)
            at 14  libdispatch.dylib                   0x00000001042dfdd4 _dispatch_call_block_and_release + 12
            at 15  libdispatch.dylib                   0x00000001042e0d48 _dispatch_client_callout + 8
            at 16  libdispatch.dylib                   0x00000001042eede6 _dispatch_main_queue_callback_4CF + 1500
            at 17  CoreFoundation                      0x00007fff23bd4049 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
            at 18  CoreFoundation                      0x00007fff23bceca9 __CFRunLoopRun + 2329
            at 19  CoreFoundation                      0x00007fff23bce066 CFRunLoopRunSpecific + 438
            at 20  GraphicsServices                    0x00007fff384c0bb0 GSEventRunModal + 65
            at 21  UIKitCore                           0x00007fff48092d4d UIApplicationMain + 1621
            at 22  My Lib                              0x0000000103327f5b main + 75 (Path-at-my-machine/myContainingApp/AppDelegate.swift:7:7)
            at 23  libdyld.dylib                       0x00007fff5227ec25 start + 1
    e
    • 2
    • 7
  • c

    christophsturm

    04/17/2020, 9:33 AM
    whats the easiest way to use a master snapshot of ktor? can i build from source just for the jvm? if using jitpack for example
    implementation("com.github.ktorio:ktor:master-SNAPSHOT")
    i get unresolved symbols for example for jetty server
    s
    • 2
    • 3
  • e

    edenman

    04/18/2020, 1:57 AM
    Anybody seen
    EOFException
    from okhttp when using ktor websockets? receiving messages works great but I get this EOF anytime I try to send a message on the socket: https://github.com/ktorio/ktor/issues/1803
    h
    • 2
    • 1
  • s

    Stan Kocken

    04/18/2020, 8:46 AM
    I love what you do with Ktor ❤️ One small remark: within the doc (for example https://ktor.io/clients/index.html), it can be nice to have somewhere always visible the latest version, I’m always having a hard time to find the latest.
    👍 9
    n
    • 2
    • 2
  • w

    waltermcq

    04/19/2020, 1:34 AM
    Question on ktor + exposed + coroutines
    t
    m
    s
    • 4
    • 17
  • v

    vishesh

    04/19/2020, 7:09 PM
    I am an experienced mobile application developer. Knows Kotlin, Swift, Dart and Java. I want to learn Server Side development suggest me a framework to start with. Thank You.
    c
    • 2
    • 6
  • c

    christophsturm

    04/20/2020, 4:35 PM
    if i send a post request like this:
    <http://client.post|client.post><String>("....") {
                    body = TextContent(stringBody, ContentType.Application.FormUrlEncoded)
                }
    does it set a content type header? if I test the code with the MockEngine it has no content type header set.
    r
    • 2
    • 5
  • s

    Sam Garfinkel

    04/21/2020, 7:56 PM
    Can pipeline interceptors handle exceptions thrown further down in the pipeline? I’m trying to add a simple interceptor that retries a call (with a delay) if the call fails. I’d like this to supplement the existing timeout/validation features.
    r
    e
    • 3
    • 20
  • a

    addamsson

    04/22/2020, 11:54 AM
    It is supposed to align, but I still get 415 form ktor. What am I doing wrong?
    e
    • 2
    • 15
  • a

    Antanas A.

    04/23/2020, 7:26 AM
    Hello, I've read in documentation that ktor supports http2 but it needs SSL/TLS which can be enabled with additional openssl netty's plugin/driver. But we're currently using HAProxy which already has a SSL support and your servers communicates in simple http mode. Is it possible in ktor to enable http2 (h2c) mode which would work without SSL/TLS encryption?
    ➕ 2
    b
    • 2
    • 2
  • a

    addamsson

    04/24/2020, 11:19 AM
    How do I perform
    Bearer
    authentication with #ktor ? I see that there is basic, jtw, etc, but there is no option for simply checking the bearer token.
    o
    r
    d
    • 4
    • 12
  • r

    Rachid

    04/24/2020, 12:18 PM
    Hi all, I'm playing around with ktor and now want to add application logging. I have a lot of
    println
    statements which I want to convert to INFO, DEBUG, etc When searching the internet I didn't find any good examples of how this could work in ktor. Only a minimal example of how to add logback for enabling logging in the frameworks used by ktor itself (like Netty). So know my question. Do you have any suggestions? And pointers/links to examples would be very helpful.
    e
    • 2
    • 3
  • o

    Orhan Tozan

    04/24/2020, 12:20 PM
    Of all the engines for JVM/Android for HTTP Client, which one is recommended?: Apache, CIO, Jetty, OkHttp, HttpUrlConnection?
    e
    g
    +3
    • 6
    • 14
  • p

    ponzii

    04/24/2020, 2:21 PM
    I generated a new Ktor project using the IntelliJ plugin. The resulting build.gradle file has mainClassName = “io.ktor.server.netty.EngineMain” but when I build a fat Jar with Gradle I get java.lang.ClassNotFoundException: io.ktor.server.netty.EngineMain.
    r
    • 2
    • 7
  • d

    Dariusz Kuc

    04/24/2020, 3:48 PM
    hello! 👋 I’m hitting a pretty weird error from
    HttpClient
    and I am unsure whats causing it, given some result object when I run the following
    lateinit var result: GraphQLResult<ExampleQuery.ExampleQueryResult>
    runBlocking {
        val graphQLRequest = mapOf(
                "query" to EXAMPLE_QUERY,
                "operationName" to "ExampleQuery",
                "variables" to variables
        )
        result = <http://ktorClient.post|ktorClient.post>("<http://localhost:8080/graphql>") {
            accept(ContentType.Application.Json)
            contentType(ContentType.Application.Json)
            body = graphQLRequest
        }
        // works fine
        println("ktor: ${result.data}")
    
        val myClient = MyClient(ktorClient, "<http://localhost:8080/graphql>")
        result = myClient.executeOperation(EXAMPLE_QUERY, "ExampleQuery", variables)
        // blows up saying cannot cast linked hash map to my result object
        println("myClient: ${result.data}")
    }
    
    class MyClient(val client: HttpClient, val url: String) {
        suspend fun <T> executeOperation(query: String, operationName: String? = null, variables: Any? = null): GraphQLResult<T> {
            val graphQLRequest = mapOf(
                    "query" to query,
                    "operationName" to operationName,
                    "variables" to variables
            )
    
            return <http://client.post|client.post>(url) {
                accept(ContentType.Application.Json)
                contentType(ContentType.Application.Json)
                body = graphQLRequest
            }
        }
    }
    any ideas why it would behave differently?
    d
    • 2
    • 4
  • a

    Anders Sveen

    04/24/2020, 6:02 PM
    Hi. 🙂 We are using KTor server (Netty engine), but seeing quite slow response times. Some of them are definitely our own fault, but some are usually fast then suddenly end up taking 20-30 seconds suddenly. The weird thing is that the front proxy closes the connection on a time out, but I can see from the logs that the call completes after the time out. My theory: The slow requests ends up blocking processing in KTor. I see the default for runningLimit is 10, does that mean max 10 parallel taks? So if 10 ends up slow, any new ones will be queued? Any thoughts on increasing the runningLimit number? Thanks. 🙂
    r
    m
    • 3
    • 18
  • j

    Jitesh

    04/26/2020, 2:38 PM
    I am working on PoC using Ktor version 1.3.2 and have written simple POST API where I send 2 string params and return the same 2 strings. BUT, I am getting this error while using POST API
    kotlinx/coroutines/io/ByteReadChannel
    Any Idea what mistake am I doing?.
    HTTP/1.1 500 Internal Server Error
    Date: Sun, 26 Apr 2020 14:30:36 GMT
    Content-Length: 37
    Connection: keep-alive
    Content-Type: text/plain; charset=UTF-8
    Server: ktor-server-core/1.3.2 ktor-server-core/1.3.2
    f
    • 2
    • 2
  • c

    coder82

    04/27/2020, 1:52 PM
    Hi guys, KTOR doesn't seem to offer an option to do something specific if the netty responseWriteTimeoutSeconds or requestReadTimeoutSeconds trigger. Basically it's closing the connection without reporting any error to the browser. Is there a way to enforce a different closure or at least send an HTTP response with error code? You can reproduce this just by sleeping in request for more than the default time of those timeouts. I want to return 408 Request Timeout and not closing the connection abruptly, doesn't make sense, does it?
    👍 2
    • 1
    • 1
  • r

    rrva

    04/28/2020, 5:47 AM
    have trouble getting openapi or swagger to work. Can anyone point me to a recent example that works?
    s
    • 2
    • 1
  • a

    Anders Sveen

    04/28/2020, 8:20 AM
    Hey. I am doing a custom AuthenticationProvider and intercepting calls (both RequestAuthentication and CheckAuthentication) and returning av 401 when my custom checks fail. But it still reaches the endpoint code even though authentication fails. Is there some way to stop further processing? I have tried (a wild guess) to
    return@intercept finish()
    but it still continues processing.... Any idea?
    • 1
    • 1
  • a

    addamsson

    04/28/2020, 9:50 AM
    Hi there! I'm trying to submit a form with the Ktor HttpClient but I get
    RedirectResponseException: Unhandled redirect: <http://127.0.0.1:9000/login>. Status: 302 Found
    This is nice because there is supposed to be a redirect but I can't figure out how to fix this. I'd like to check that the user was redirected to
    /
    after login.
    s
    • 2
    • 2
  • c

    crummy

    04/28/2020, 11:28 PM
    How do I register a customer serializer for a class using kotlinx serialization in Ktor?
    e
    s
    • 3
    • 15
  • i

    Imran

    04/29/2020, 11:42 AM
    I am trying to get static files it is working with file extensions  like 
    /static/xyz.json
     but I want access it like  
    /static/xyz
     . can anyone know how to do it?
    • 1
    • 1
  • d

    dylan

    04/29/2020, 3:06 PM
    How do I set up the
    HttpClient
    with kotlinx.serializtion where every api endpoint has a custom vendor specific content-type? if I use the
    accept()
    function with multiple content-types they are also added to the accept header on the request which I don't want because we already specifiy that where I make the actual request. So api call
    A
    needs to send
    Accept: application/vnd.a
    and in return will get the
    Content-Type: application/vnd.a
    back in the response header and
    B
    sends
    application/vnd.b
    and is going to get
    application/vnd.b
    back. but I get NoTransformationFoundException: ByteBufferChannel => Serializable data class.
    a
    • 2
    • 2
Powered by Linen
Title
d

dylan

04/29/2020, 3:06 PM
How do I set up the
HttpClient
with kotlinx.serializtion where every api endpoint has a custom vendor specific content-type? if I use the
accept()
function with multiple content-types they are also added to the accept header on the request which I don't want because we already specifiy that where I make the actual request. So api call
A
needs to send
Accept: application/vnd.a
and in return will get the
Content-Type: application/vnd.a
back in the response header and
B
sends
application/vnd.b
and is going to get
application/vnd.b
back. but I get NoTransformationFoundException: ByteBufferChannel => Serializable data class.
a

Ayman Izzeldin

04/29/2020, 6:40 PM
if I understand the question correctly, you can create a copy of the http client, and reconfigure it (this new client will reuse the same underlying engine.) Something along the lines of:
val apiAClient = myHttpClient.config {
    Json { acceptContentTypes = acceptContentTypes + ContentType.parse("application/vnd.a") }
}
d

dylan

04/29/2020, 9:13 PM
Seems a bit boilerplaty to copy an instance of the httpclient for every separate api call we make
View count: 6