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

    Jonathan Mew

    01/25/2022, 10:07 AM
    Spotted a typo in CONTRIBUTING.md:
    sudo apt-get libcurl
    E: Invalid operation libcurl
    https://github.com/ktorio/ktor/blob/main/CONTRIBUTING.md?plain=1#L43 Happy to make a PR to fix if you let me know the intention.
    sudo apt-get install libcurl-dev
    will at least suggest some candidates? (I am on Ubuntu 20.04)
    e
    • 2
    • 4
  • t

    turansky

    01/25/2022, 4:53 PM
    How I can legalize
    /
    in the end for Ktor?
    /items
    ==
    /items/
    r
    • 2
    • 1
  • o

    Osman Saral

    01/25/2022, 9:48 PM
    Can I intercept a request before it's even sent and simulate the response? The use case is, our token is killed after a while and we want to refresh the token, without getting an unauthorized response from server. If the mentioned time is elapsed, client should know it and refresh the token automatically. I've added what I've tried below:
    a
    • 2
    • 9
  • b

    brabo-hi

    01/25/2022, 11:42 PM
    Hi all, when using Ktor, how can i log
    request Body
    ?
    a
    • 2
    • 4
  • z

    zfan93

    01/26/2022, 2:49 AM
    Does Ktor support JPA ?
    a
    • 2
    • 1
  • v

    Václav Škorpil

    01/26/2022, 8:29 AM
    Hi, do you know how to set up proxy with authentication for ktor client using CIO engine on jvm. In documentation there is only this and no further details. "Proxy authentication and authorization are engine specific and should be handled by the user manually."
    a
    d
    • 3
    • 3
  • b

    ByteZ

    01/26/2022, 4:17 PM
    Hey guys! Is there a better way to receive a UTF-8 String from a post request than
    call.receive<ByteArray>().toString(Charsets.UTF_8)
    ? I'm aware that
    call.receiveText()
    exists but we had some encoding issues after receiving a request containing a "Fullwidth Colon" (U+FF1A).
    a
    • 2
    • 6
  • c

    cafonsomota

    01/26/2022, 4:28 PM
    hello all! I was looking at the change log of ktor 2.0.0-beta1, and I’ve noticed that there’s XML support for the client: • https://github.com/ktorio/ktor/commit/0acc7080d40b1978c62e39be20470ae971417bde If I’m not mistaken, the library to import should be this one, right?
    implementation("io.ktor:ktor-serialization-kotlinx-xml:2.0.0-beta-1")
    However, it seems that I’m unable to use it at the moment - no classes found - at Multiplatform level (Kotlin 1.6.10). Is there something that I might be missing?
    b
    a
    • 3
    • 5
  • j

    Javier

    01/26/2022, 5:06 PM
    Is it possible to go get inner types with
    ContentNegotiation
    before passing it to
    Kotlin Serialization
    ? In
    commonMain
    probably with reflection can be done but I am not finding a way to transform from
    Type
    ,
    KType
    or
    KClass
    to to an inner type in KMP (KTOR 2.0.0)
    a
    • 2
    • 3
  • b

    brabo-hi

    01/26/2022, 9:14 PM
    Hi, on ktor
    1.x
    we could do
    <http://client.post|client.post><MyResponseType>(""){}
    but it
    2.x
    we can’t specify the return type directly?
    r
    • 2
    • 1
  • b

    brabo-hi

    01/27/2022, 12:07 AM
    Hi, what is the difference between
    <http://httpclient.ws|httpclient.ws>()
    and
    httpclient.websocket()?
    a
    • 2
    • 3
  • a

    Alan Ramirez

    01/27/2022, 3:27 AM
    Hello guys, I am new to Ktor and the documentation seems to fall a bit short for me could anyone give me advice or resources to fix my issue? Thank you https://stackoverflow.com/questions/70872686/project-fatjar-not-found-in-root-project
    d
    • 2
    • 2
  • r

    Rover Sanchez

    01/27/2022, 11:23 AM
    Hi guys, Has anybody else troubles trying to include the "io.ktor:ktor-client-okhttp:2.0.0-beta-1" dependency? It just could not resolve although I've included google an maven Central repository
    a
    m
    • 3
    • 63
  • j

    jean

    01/27/2022, 2:40 PM
    I created a ticket for an issue I just encountered : https://youtrack.jetbrains.com/issue/KTOR-3756
    • 1
    • 1
  • r

    Rafał Kuźmiński

    01/27/2022, 5:43 PM
    Hello guys, I'd like to setup CORS in Ktor server to match every of our product, which would be xxx.ourname.com and xxx.ourname.pl. I cannot find any way to set CORS by regex / predicate, only hardcoded strings. How can I do it?
    r
    • 2
    • 1
  • b

    brabo-hi

    01/27/2022, 11:10 PM
    how to read deserialized incoming messages continuously ? or as a flow in
    ktor 2.x
    ? Should we read in a
    while(true){}
    client.wss() {
       while (true) {
          val customer = receiveDeserialized<Customer>()
       }
    }
    a
    d
    • 3
    • 4
  • l

    Laurence

    01/28/2022, 8:36 AM
    Is anyone here using Ktor backend to serve and consume gRPC endpoints?
    e
    • 2
    • 2
  • j

    Javier

    01/28/2022, 1:48 PM
    the new APIs for creating plugins are only for server or there are for client too?
    a
    • 2
    • 1
  • j

    Javier

    01/28/2022, 3:04 PM
    I am trying to get the
    converters
    in my plugin via
    scope.pluginOrNull(ContentNegotiation)
    , but they are internal, is it possible to get them in another way?
    a
    • 2
    • 2
  • b

    ByteZ

    01/29/2022, 3:39 PM
    Is there a way to make the trailing
    /
    in routes optional? For example I want both
    localhost/test
    and
    localhost/test/
    to work.
    a
    • 2
    • 2
  • v

    Victor Yakovlev

    02/01/2022, 11:22 AM
    How to use raw socket in common source set after update to 2.x version?
    a
    • 2
    • 3
  • с

    Стефан Јовановић

    02/01/2022, 4:45 PM
    I'm trying to create an Android App which will communicate with Ktor server. I have successfully established a session with those two. And everything seems to work fine. On my Android app I've implemented One Tap sign in with Google, so whenever a user is authenticated, I receive a TOKEN which I'm sending to my Ktor server for verification. After it is successfully verified, I'm then saving users credentials on the server. For the session storage I'm using "directorySessionStorage". There's just one thing that's troubling me right now, and I'm hitting the wall. So whenever I launch my Android App, I'm signing in and immediately starting a NEW session with Ktor server. The only problem is, that the OLD session is not deleted even after a NEW one was created. Now I can remove that OLD SESSION if the user clicks SIGN OUT button in my Android app explicitly. However if the user just closes the app and launch it again without clicking SIGN OUT button, then that OLD SESSION will not be deleted, and a NEW one will be created, with new app launch. That way I'm seeing new session on my server directory every time a same USER launches the app again without SIGNING OUT explicitly. I don't want that, I want to remove the OLD SESSION, whenever a NEW one is created for that same USER. I'm not sure about the actual logic which needs to be implemented for that, can someone point me in the right direction? 🤔 Or is there any way that I can manually set the time limit on a session?
    a
    • 2
    • 6
  • j

    Jan

    02/01/2022, 5:28 PM
    I'm using ktor on android and using it over a Wifi connection works fine but over mobile data a simple GET request returning json takes 10+ seconds (I measured 10mbit/s). Is that somehow my fault?
    m
    a
    • 3
    • 4
  • h

    hhariri

    02/02/2022, 6:24 AM
    FEEDBACK NEEDED Folks, 2.0 is around the corner, and we are polishing up the last of our work on the new version. As you may be aware, we’re going to introduce a new API for writing custom plugins that is fluent and easy to use (you can read more about here https://ktor.io/docs/eap/custom-plugins.html) We’ve made a new plugin API to extend the existing one with the same types.
    val DataTransformationPlugin = createApplicationPlugin(name = "DataTransformationPlugin", ::Config) {
        // ...
    }
    It turns out that if the library mode is enabled, it becomes a bit more complicated to read because of the type:
    public val DataTransformationPlugin: ApplicationPlugin<Application, Config, PluginInstance> = createApplicationPlugin(name = "DataTransformationPlugin", ::Config) {
    }
    where Application and PluginInstance are fixed. We’re thinking about several options on how we can solve this: First option Drop obsolete generic parameters from
    ApplicationPlugin
    and keep it as
    ApplicationPlugin<Config>
    We need to introduce
    _NAME_ApplicationPlugin<Application, Config, PluginInstance>
    replacement for existing plugins, so it will be a breaking change.
    public val DataTransformationPlugin: ApplicationPlugin<Config> = createApplicationPlugin(name = "DataTransformationPlugin", ::Config) {    // ...
    }
    Second Option Introduce typealias
    _NAME_<Config>
    and keep
    ApplicationPlugin
    as it is.
    public val DataTransformationPlugin: NAME<Config> = createApplicationPlugin(name = "DataTransformationPlugin", ::Config) {
        // ...
    }
    Third Option Keep
    ApplicationPlugin<Application, Config, Instance>
    as it is. The problem with introducing NAME is precisely what we could call something that actually already has a name, i.e. ApplicationPlugin. Anything along the lines of “Default”, “Simple” or similar incorrectly could lead to the wrong assumptions. What are your thoughts on this?
    1️⃣ 5
    🚀 3
    🎉 3
    👏 1
    👍 2
    b
    s
    • 3
    • 3
  • n

    Nikolay Kasyanov

    02/02/2022, 10:28 AM
    hey folks, does ktor provide some client-side compression out of the box? KTOR-1199 makes me think it does not 😞
    d
    a
    • 3
    • 4
  • s

    S.

    02/02/2022, 2:38 PM
    I'm trying to write unit tests for a post request but I'm having problems with the serialization:
    Fail to serialize body. Content has type: class .models.NewWord, but OutgoingContent expected.
    java.lang.IllegalStateException: Fail to serialize body. Content has type: class .models.NewWord, but OutgoingContent expected.
    If you expect serialized body, please check that you have installed the corresponding plugin(like `ContentNegotiation`) and set `Content-Type` header.
    My test according to the docs (2.0.0 btw) :
    testApplication {
                    val c = createClient {
                        install(ContentNegotiation) {
                            json()
                        }
                    }
                    val r = c.post("/word") {
                        contentType(ContentType.Application.Json)
                        setBody(NewWord("a", "b", "c"))
                    }
                }
    I also tried header() instead of contentType() but doesn't work either
    header(HttpHeaders.ContentType, ContentType.Application.Json.toString())
    the NewWord class is Serializable ofc. what am I missing?
    r
    a
    • 3
    • 8
  • g

    gps

    02/03/2022, 11:55 AM
    Hey folks, I was wondering if there's an “official” way of measuring and logging response times in ktor? I know there's micro meter and dropwizard registry integration but that doesn't appear to include the response time out of the box?
    l
    • 2
    • 1
  • l

    Landry Norris

    02/03/2022, 3:42 PM
    I noticed that Ktor client only supports x64 Desktop targets. Is there a way to use it with macosArm64 for M1 Macs?
    h
    j
    • 3
    • 3
  • m

    Michael Langford

    02/03/2022, 5:46 PM
    2: When using ktor to do multipart posts, can you do that without a content-length on each section?
    a
    • 2
    • 2
  • j

    Jorge Bo

    02/03/2022, 5:59 PM
    Hi, is it possible to stream a flow in ktor ? Couldn't find any example in docs
    h
    • 2
    • 2
Powered by Linen
Title
j

Jorge Bo

02/03/2022, 5:59 PM
Hi, is it possible to stream a flow in ktor ? Couldn't find any example in docs
h

hfhbd

02/03/2022, 6:01 PM
What do you want to stream? And how? Websockets?
j

Jorge Bo

02/03/2022, 6:13 PM
i would like to publish elements in a Flow as soon as they are ready, coming from spring i remember that with webflux i had only to return a Flux from the controller and elements where available. I assume that it should be http. I mean somehow the framework should "collect" the flow in order to start streaming. Not sure if that works out of the box
View count: 5