https://kotlinlang.org logo
Docs
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
  • a

    andrew

    08/01/2019, 9:55 PM
    I’d like to adapt it to something like this:
    List<PaymentStripeCard>
    g
    • 2
    • 7
  • u

    4ntoine

    08/02/2019, 7:25 AM
    Hey, guys. I need to parse URL in K/M (for Native). I’ve added
    implementation "io.ktor:ktor-client-core:1.2.3"
    in common sourseSet and
    implementation("io.ktor:ktor-client-curl:1.2.3")
    in native sourcesSet (
    macosX64
    actually). I can’t access
    io.ktor.http.Url
    in native code:
    NativeURL.kt: (3, 8): Unresolved reference: io
    Is it multiplatform? Wrong imports? I can see “io.ktor-ktor-http:1.2.3” actually shown in External deps in IDEA. Any suggestions on how to proceed?
    e
    d
    • 3
    • 46
  • b

    Big Chungus

    08/02/2019, 8:23 AM
    Is there a library that provides Kotlinx.serialization as a ContentNegotiation feature?
    g
    e
    c
    • 4
    • 12
  • s

    Shan

    08/04/2019, 1:47 AM
    Hey all, did the latest update make Ktor usable on older versions of Android SDK (21+)? I can't get to a computer to test it out unfortunately
    s
    • 2
    • 2
  • u

    4ntoine

    08/05/2019, 7:40 AM
    Hey, guys. Does Ktor support punycode (googled a bit but found nothing)? Looking for some util methods to convert ascii <-> unicode
    b
    g
    y
    • 4
    • 34
  • m

    Manuel Lorenzo

    08/05/2019, 8:53 AM
    hi all! I’m trying to create my first test: a simple one like
    class ApplicationKtTest {
        @Test
        fun test1() = withTestApplication({ module(testing = true) }) {
            with(handleRequest(HttpMethod.Get, "/")) {
                assertEquals(HttpStatusCode.OK, response.status())
            }
        }
    }
    but I get
    Execution failed for task ':test'.
    > No tests found for given includes: [ApplicationKtTest.test1](filter.includeTestsMatching)
    e
    • 2
    • 3
  • m

    Manuel Lorenzo

    08/05/2019, 1:00 PM
    anybody with more experience in CircleCI? could it be that
    bash
    isn’t installed?
    y
    • 2
    • 5
  • y

    yschimke

    08/05/2019, 1:12 PM
    For the ktor http client, if it follows redirects. Is there a way to know the final URL?
    e
    • 2
    • 3
  • c

    christophsturm

    08/06/2019, 5:15 PM
    get requests can have a body
    b
    • 2
    • 1
  • b

    Big Chungus

    08/07/2019, 9:14 AM
    I keep getting
    INFO - 200 OK: GET - <route>, channel failed
    e
    • 2
    • 1
  • m

    mantono

    08/08/2019, 6:43 AM
    I am bit confused. Version 1.2.3 of Ktor has breaking changes (as stated in the release notes) and it did indeed break my code - does Ktor not use semantic versioning or is there something I haven't grasped? (also I don't get it to compile even if I use Kotlin 1.3.41).
    h
    f
    • 3
    • 6
  • v

    voddan

    08/08/2019, 12:43 PM
    Hi! How do I use a Ktor server with a custom logging framework, say
    kotlin-logging
    ? Couldn't find it in the docs. The less xml the better. Thanks!
    s
    n
    • 3
    • 8
  • b

    Big Chungus

    08/08/2019, 3:24 PM
    Hello, how do i get the ktor-client's error response's body?
    HttpResponse.readText()
    is throwing an exception
    e
    d
    • 3
    • 2
  • t

    Tony Blundell

    08/09/2019, 3:56 PM
    Hi are there any examples of XML serialisation with Ktor / Ktor Client?
    s
    m
    • 3
    • 3
  • c

    Christoph Schnabl

    08/09/2019, 6:46 PM
    Hey, does anyone know how to use a local ktor gradle build in another application to test a feature?
    c
    • 2
    • 2
  • n

    nyxcode

    08/10/2019, 7:00 PM
    Suprisingly, I couldn't find a trustworthy coroutines MariaDB/JDBC driver - why is that?
    n
    y
    • 3
    • 3
  • w

    wuseal

    08/11/2019, 5:16 AM
    message has been deleted
    e
    • 2
    • 2
  • t

    tseisel

    08/12/2019, 7:38 AM
    I'm trying to write an
    HttpClient
    feature for handling OAuth authentication. Here is how it should operate : 1. On each request, if a valid auth token is available, then perform the request by adding the
    Authorization: Bearer <token>
    2. If no token is available or the token expired, then perform a request on a configurable authentication endpoint with provided credentials. If authentication succeeds, save the received token and perform the initial request with the
    Authorization
    header. I've seen that this kind of features can be implemented using
    HttpClient
    pipelines, but can't find how to use them with my use case. What pipeline/phase should I use ? How to perform the authentication request with the same config (for example JSON deserialization) as the initial request ?
    e
    • 2
    • 3
  • t

    Thomas

    08/12/2019, 1:00 PM
    In my app some users get a timeout exception. This exception is not caught by my code. The stack trace shows no lines referencing my code so I have some difficulties finding the cause. I created an issue about this on GitHub (https://github.com/ktorio/ktor/issues/1263). Does anyone have any suggestions how I could approach this?
    m
    • 2
    • 5
  • l

    Ludd

    08/12/2019, 4:05 PM
    Hi, All! I got an issue with leaking sockets in CLOSE_WAIT state. I have a ktor server connecting with mobile clients using websockets. Websocket handling cycle is just copied from chat demo application for ktor: private suspend fun DefaultWebSocketServerSession.handleWebSocketSession() { val session = WebSocketSession(this, sessionService) try { for (frame in incoming) { if (frame is Frame.Binary) session.handleFrame(frame, endpoints) else if (frame is Frame.Text) close(CloseReason(CloseReason.Codes.PROTOCOL_ERROR, "Text frames are not supported")) } } finally { session.close() } } My server is behind an AWS Application Load Balancer. There are some descriptions of what to do with a growing number of CLOSE_WAIT sockets for netty, but I don't see how they can be applied to this cycle. Did anybody hit this issue or know where to look?
    👀 2
    • 1
    • 3
  • v

    Vinicius Araujo

    08/13/2019, 5:24 PM
    Hi everyone! Is MVC a good pattern for ktor applications? Is there any other pattern recommended?
    s
    • 2
    • 3
  • n

    Nick

    08/13/2019, 8:27 PM
    Hello everyone! If I subscribe to the environment monitor like
    environment.monitor.subscribe(ApplicationStarted)
    every time hot-reload happens it will subscribe one more function subscribed call. is this behaviour normal?
    s
    • 2
    • 6
  • d

    davidasync

    08/14/2019, 5:27 PM
    Hello sorry for noob question, I'd like to ask about how could I get query parameters in array for example I have this endpoint, I want to get books that have genre romance or comedy from this route http://localhost:3001/books?genre=romance&amp;genre=comedy I'm using this code
    val genre = call.request.queryParameters["genre"]
    but only return the first genre which is
    romance
    m
    s
    a
    • 4
    • 4
  • k

    keochris

    08/15/2019, 3:07 PM
    Hello, sorry for the noob question (new to Kotlin and JVM world). After succeeding in generating a working fat jar file with Shadowjar, I’d like to know how I can create an external config file to be used with that fat jar so that parameters can be read from that external file. Something similar to the application.conf but not in the jar itself so that we can amend the values whenever needed. Thanks for your help !
    d
    k
    • 3
    • 8
  • s

    Sam

    08/15/2019, 3:52 PM
    I have an api that returns a json payload that has a number of keys of object ids and then the objects.
    {
      "-ZxqaLK58wkKYwibR4PMP": {"prop1": "val1", "prop2": "val2"},
      "-fdsafDEW34fSDFjnowe": {"prop1": "val3", "prop2": "val4"},
    }
    I'm using kotlinx.serialization to deserialize them but am encountering the error:
    kotlinx.serialization.SerializationException: Can't locate argument-less serializer for interface java.util.Map
    when I invoke the service with
    <http://httpClient.post|httpClient.post><Map<String, MessageResult>>(urlStr)
    The error message says that I should provide the serializer explicitly. Is that something I have to configure in my serializer module or something I have to tell ktor's json feature to do?
    d
    • 2
    • 5
  • c

    coder82

    08/15/2019, 11:01 PM
    [SOLVED] I have this get shown below very simple, does nothing pretty much. I want to simulate an API call which takes 5 seconds to process. If I send 5 http requests within one second, from the trace I see ktor processing one at a time logging: call incoming! call finished! call incoming! call finished! call incoming! call finished! call incoming! call finished! .... This is not what I wanted, what I expected was: call incoming! call incoming! call incoming! call incoming! call incoming! call finished! call finished! call finished! call finished! call finished! Why is ktor not processing the calls in parallel?? @e5l @cy I have 4+4 connectionGroupSize/workerGroupSize threads shared and 8 callGroupSize all setup
    Untitled.txt
    e
    d
    • 3
    • 52
  • a

    Alexander

    08/16/2019, 1:02 PM
    Hi there. Trying to build url with path containing special symbols:
    URLBuilder(host = "localhost").apply {
        path("%?")
        parameters["?"] = "?"
    }
        .buildString()
        .also(::println)
    The above code produces
    <http://localhost/%25??%3F=%3F>
    url. The question mark in the path is not encoded. I whould expect the following:
    <http://localhost/%25%3F?%3F=%3F>
    . If I encode it explicitly
    path("%?".encodeURLPath())
    the percent sign is encoded twice.
    • 1
    • 1
  • l

    Leon K

    08/18/2019, 1:38 PM
    hey, i have a problem with the ktor client auth feature not being available altough it is installed in the gradle dependency block. I used the regular ktor-project wizard in intelliJ, and added the basic auth feature on the client side, but when i try to
    install(Auth)
    in an HttpClient, the class doesn't seem to exist. also, the dependency that is installed by the wizard is
    compile "io.ktor:ktor-client-auth-basic:$ktor_version"
    , whilst in the ktor doc (https://ktor.io/clients/http-client/features/auth.html) the mentioned dependency is
    "io.ktor:ktor-client-auth:$ktor_version"
    ... any ideas?
    d
    t
    • 3
    • 9
  • s

    shengyou

    08/20/2019, 5:12 AM
    Hello, I'm new in Ktor. And I'm searching how to integrate migration and cron job feature into Ktor (like such feature in Laravel or Rails). Is there any suggestion package or I'm doing it in a wrong way? Thanks!
    v
    e
    d
    • 4
    • 8
  • b

    bitkid

    08/20/2019, 2:35 PM
    is there a way to use respondTextWriter {} but write the http status of the request before the first write operation? something like passing ()->Int instead of the actual status?
    • 1
    • 3
Powered by Linen
Title
b

bitkid

08/20/2019, 2:35 PM
is there a way to use respondTextWriter {} but write the http status of the request before the first write operation? something like passing ()->Int instead of the actual status?
what i am trying to do is to transform data from a jdbc resultset to a response as memory efficient as possible. the query runs in a different context so what i do in protocode is:
call.respondTextWriter { db.query { write(rs.next())}}
but all exceptions within the respondTextWriter block should actually lead to a different http status code. what i could do is something like
db.query{call.respondTextWriter {}}
but i would need something like launch{} in that code and its a bit ugly to pass the call into that function
what i totally want to avoid is collecting all the data from the result set before writing it back
should i go for my own implementation of WriteChannelContent / OutgoingContent?
View count: 4