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
  • t

    Trey

    04/27/2022, 1:49 PM
    We use token authentication with our app. Can somebody point me to an example of how to configure the bearer section so that the auth/refresh token can be shared across more than one http client? We have two different servers (dept1.mycompany.com and dept2.mycompany.com) that use the same auth token.
    a
    • 2
    • 2
  • m

    MJegorovas

    04/27/2022, 2:15 PM
    Please fix docs by adding that darwin supports websockets too: https://ktor.io/docs/websocket-client.html#add_dependencies
    e
    d
    • 3
    • 2
  • p

    Peter

    04/27/2022, 5:27 PM
    attempting to migrate to Ktor 2: any idea what happened to
    Authentication.ChallengePhase
    ?
    r
    a
    r
    • 4
    • 10
  • s

    Slackbot

    04/27/2022, 6:55 PM
    This message was deleted.
    j
    • 2
    • 2
  • m

    MJegorovas

    04/28/2022, 11:01 AM
    Why only
    headers.append
    have a method with
    HeaderValueWithParameters
    as second parameter and other
    append*
    don't? If only
    append
    should have this, then this doc needs to be fixed: https://api.ktor.io/ktor-client/ktor-client-core/io.ktor.client.plugins/-default-request/index.html (see "usage" box).
    a
    • 2
    • 3
  • p

    Paul SOUTEYRAT

    04/28/2022, 4:13 PM
    Hi, we are trying to migrate to ktor 2.0 but we are encountering an issue about websocket deserialization. Indeed, after inspecting the problem, it seems the issue comes from the JacksonWebsocketContentConverter. We detailed the problem on youtrack. Any idea on how we can get around this issue ?
    a
    • 2
    • 2
  • m

    Miquel Àngel Román

    04/28/2022, 8:58 PM
    Since Ktor 2.0.0 it should be able to be compiled as a native target. Any guide or sample that does so?
    a
    • 2
    • 2
  • h

    hhariri

    04/29/2022, 9:37 AM
    📣 Ktor 2.0.1 is now available. https://ktor.io/changelog/2.0/ 📣
    :ktor: 8
    🙌🏼 1
    🙌 3
    👍 2
    ❤️ 6
    • 1
    • 1
  • m

    MJegorovas

    04/29/2022, 11:36 AM
    Is there a way to change how client query parameters in
    Resource
    are serialized? Now i get
    <http://example.com?ids=1&ids=2|example.com?ids=1&ids=2>
    , but I would want
    <http://example.com?ids=[1|example.com?ids=[1>, 2]
    a
    r
    • 3
    • 3
  • d

    David Stibbe

    04/29/2022, 1:21 PM
    Does anyone generate OpenApi yaml's from their Ktor endpoints ?
    j
    d
    +2
    • 5
    • 5
  • v

    Vivek Modi

    04/29/2022, 1:46 PM
    Hey how to get error code, error response and body through HttpResopnse in ktor?
    t
    • 2
    • 1
  • b

    bbaldino

    04/29/2022, 4:59 PM
    Is there a good way to scope an
    Application.configureRoutes()
    -type method within a class to be able to add additional context? For example, I want to be able to fire events when a new websocket is established, so want a way to store a sort of ‘event emitter’, and therefore allow external entities to be able to subscribe to those events. I think maybe the new
    Context Receivers
    would handle this? But looking for another way since those are still experimental.
    l
    j
    • 3
    • 8
  • m

    Muhammad Talha

    04/30/2022, 5:51 AM
    Hello! Is there any way to set development mode using the embeddedServer? I see instructions for EngineMain here (https://ktor.io/docs/development-mode.html) but not for the embeddedServer. Thanks!
    d
    • 2
    • 3
  • d

    Dragos Rachieru

    05/02/2022, 9:13 AM
    Hello, I am trying to create a multiplatform image loading library, I use
    ktor
    for remote loading and
    okio
    for local loading(files). I want to have an interface for fetcher that returns a flow of
    Loading(progress)
    ,
    Success(something)
    ,
    Error(throwable)
    I am not sure what
    something
    should be to support both fetchers.
    a
    • 2
    • 7
  • a

    Andreas Scheja

    05/02/2022, 11:45 AM
    I'm currently upgrading one of my projects to ktor V2, but using the new plugin API there is no (non-internal) way to
    finish()
    a call from inside a
    onCall
    handler. Is that intended?
    e
    • 2
    • 5
  • p

    Peter

    05/02/2022, 6:01 PM
    encountering an odd error trying out porting an existing working application (1.6.8) to ktor 2.0.1:
    a
    • 2
    • 8
  • b

    bbaldino

    05/02/2022, 9:56 PM
    In the websocket example (on this page) it states that:
    In this sample, the infinite loop is only exited with an exception is risen: either a ClosedReceiveChannelException or another exception.
    but when I do a test with postman and hit “disconnect” on the postman side, no exception is thrown in ktor: instead the
    for (frame in incoming)
    loop just exits. Is this also a possible “close” behavior?
    d
    • 2
    • 2
  • g

    Garry Heaton

    05/03/2022, 12:44 AM
    If I add -port-8080 in Run > Edit Configurations > Program arguments I get another error: “system properties: No configuration setting found for key ‘ktor’” . WTF!?
    m
    • 2
    • 2
  • d

    Dragos Rachieru

    05/03/2022, 7:42 AM
    Hello, I am trying to use
    ktor-client-curl
    but it fails with error:
    lld: error: unable to find library -lcurl
    I am using
    ArchLinux
    and I have
    curl
    installed using
    pacman -S curl
    Running
    curl
    from terminal works.
    l
    • 2
    • 5
  • b

    bbaldino

    05/03/2022, 10:44 PM
    is there any good pattern to do the handling of websocket messages outside the
    webSocket
    block? I’m trying to do something like:
    webSocket("/ws") {
        val webSocketTransport = WebSocketTransport(this)
        eventHandler.newWebSocketConnected(webSocketTransport)
    }
    where the
    WebSocketTransport
    launches a coroutine to read the incoming messages:
    scope.launch {
        for (msg in webSocketSession.incoming) {
            ...
        }
    }
    but when I try this, the websocket disconnects immediately, because it looks like it’s implemented in a way to close as soon as the passed
    handler
    returns. Is there any good pattern move that logic out? I did it one way where I added another channel, and the webSocket handler read messages and wrote them to that channel, and WebSocketTransport read from that channel, but was hoping to avoid having to create the intermediary.
    e
    r
    a
    • 4
    • 20
  • h

    hruan

    05/04/2022, 9:53 AM
    Hi, I’ve run an issue with testing a Ktor app where the test client receives a response with status
    415
    when
    201
    is expected. Running the app and calling the same endpoint via curl works as expected, leading me to believe that I’ve done something wrong with the test client setup. Any pointers would be appreciated. Details in thread.
    • 1
    • 3
  • r

    ribesg

    05/04/2022, 10:03 AM
    Any reason the first code example here uses
    header(…)
    and not
    contentType(…)
    ? https://ktor.io/docs/testing.html#form-data
    a
    • 2
    • 1
  • k

    KamilH

    05/04/2022, 10:09 AM
    I’m trying to migrate to ktor 2.0 and I’m facing an issue with tests. Currently I’m using
    withTestApplication
    where I call
    Application.module
    function with some arguments like that:
    withTestApplication({
        module(appModule = appModule)
    }) { ... }
    now we are suppose to use
    testApplication
    function that seemingly calls
    Application.module
    function automatically, so passing custom arguments seems not possible anymore and it makes testing much more difficult. Is there any way to call
    Application.module
    manually? Is there any workaround?
    p
    h
    r
    • 4
    • 12
  • a

    Alejandro Moya

    05/04/2022, 3:46 PM
    Hey 😄 , I started a multiplatform mobile library and I’m having an issue with the native/ios side, the code compiles but on the IDE looks as if the library was missing, could I ask for some help on that?
    d
    a
    • 3
    • 4
  • t

    Trey

    05/04/2022, 8:31 PM
    Is there a way to have the client rebuild a url when establishing a web socket connection? My company requires the token to be in the query param because browsers can't use headers for a web socket. The AuthProvider refreshes the token successfully, but then uses the same url on the retry connection, which causes it to fail with a 401 response again.
    a
    • 2
    • 1
  • j

    Jan Groen

    05/05/2022, 3:35 PM
    Hey o/ I wanted ot start a ktor 2.0.1 (or 2.0.0, tried both) project, but Windows Defender flags several Artifacts from the jetbrains ktor repo as trojans. Specifically it's having issues with these files for me:
    C:\Users\<username>\.gradle\caches\modules-2\files-2.1\io.ktor\ktor-server-netty-jvm\2.0.1\6210e26a36285251b7822bddc484c8a4fd71569c\ktor-server-netty-jvm-2.0.1.jar
    and
    C:\Users\<username>\.gradle\caches\modules-2\files-2.1\io.ktor\ktor-server-auth-jvm\2.0.0\ab5f2ce194ed07ca79bf5a7c298a757b000f37b9\ktor-server-auth-jvm-2.0.0.jar
    System reboots/updates seem to not solve the problem. Gradle reimports/version changes don't seem to do the trick either. Does anyone know of similar issues?
    a
    • 2
    • 6
  • b

    Brent Beardsley

    05/05/2022, 8:44 PM
    hey I'm using ktor 2.0 and am making a plugin to piggy back off the content negotiation plugin and would like to find out which content-types are installed? So far I've only been able to accomplish it using reflection but that won't fly long-term. I started with
    application.pluginOrNull(ContentNegotation)
    and I can see that it's installed I just can't get to it's config and registrations without reflection that I can see.
    a
    • 2
    • 1
  • t

    thana

    05/06/2022, 6:59 AM
    Is there a major design flaw in the websockets client api, or am i missing something? you can call
    receiveDeserialized
    on the
    DefaultClientWebSocketSession
    but sooner or later this will inevitably result in an exception: as soon a Ping or a Close frame arrives this fails. Wouldn;t you actually need something like
    frame.readDeserialiing()
    or similar, so you could write something like
    for(frame in incoming){ 
      when(frame.frameType)  {
       FrameType.TEXT -> frame.readDeserialzied()
       FrameType.CLOSE -> return;
    }
    }
    ?
    e
    a
    • 3
    • 7
  • v

    Vivek Modi

    05/06/2022, 8:54 AM
    Hey guys I am working on Custom Exception in ktor. I am seeing this example. I just notice in
    ResponseException
    have second paramter
    cachedResponseText
    . Do you guys know what is
    cachedResponseText
    ?
    ResponseException(response, cachedResponseText)
    a
    • 2
    • 2
  • r

    Ryan Brink

    05/07/2022, 2:31 AM
    Hey 👋 I’m just beginning work on exploring migrating kompendium https://github.com/bkbnio/kompendium to Ktor 2… I am currently exploring the shiny new route level plugins and am wondering, is there any way to update application plugin state with information provided from a route level plugin? Should specify, I don’t want this to be call state, I see that you can use attribute keys to share data across the call stack. This would be state that is set at the application startup, essentially using the route level plugins to feed back into the application level open api spec, allowing you to compose the spec from the individual routes
    b
    a
    • 3
    • 4
Powered by Linen
Title
r

Ryan Brink

05/07/2022, 2:31 AM
Hey 👋 I’m just beginning work on exploring migrating kompendium https://github.com/bkbnio/kompendium to Ktor 2… I am currently exploring the shiny new route level plugins and am wondering, is there any way to update application plugin state with information provided from a route level plugin? Should specify, I don’t want this to be call state, I see that you can use attribute keys to share data across the call stack. This would be state that is set at the application startup, essentially using the route level plugins to feed back into the application level open api spec, allowing you to compose the spec from the individual routes
b

Brent Beardsley

05/07/2022, 12:04 PM
I’m using attribute keys to do this. I created a swagger extension method on Route that adds the open api data to a list in attributes. Then in a later plugin I process that data into the open api spec
I'm using Resources (instead of Locations)
r

Ryan Brink

05/07/2022, 2:25 PM
Oh interesting… so attribute keys work across any event hook, not just the call related ones? I’ll have to try that out
a

Aleksei Tirman [JB]

05/08/2022, 8:29 AM
You can store your data in the application’s attributes that is accessible via
call.application.attributes
in the context of a route’s handler.
View count: 3