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

    Giovanni Alluvatti

    07/14/2020, 12:18 PM
    Hello, does anybody know if ktor offer a feature similar to Spring Events Publisher. I mean, I know that you can subscribe to Ktor application events, but would be nice to know if I can throw my CustomEvent and having a custom listener that handle that event.
    m
    m
    • 3
    • 4
  • n

    Nikolay Kasyanov

    07/14/2020, 12:38 PM
    Folks, does
    HttpCache
    feature work on iOS? I’ve stumbled upon this and am confused: https://github.com/ktorio/ktor/issues/992.
    h
    • 2
    • 2
  • p

    Petr Makagon

    07/14/2020, 7:45 PM
    Any suggestions how to fix below which happened under server CIO load test:
    io.ktor.server.cio.HttpServer Fatal exception in coroutines machinery for DispatchedContinuation[ExperimentalCoroutineDispatcher@4bf56b31[scheduler = DefaultDispatcher@1571ced[Pool Size {core = 2, max = 128}, Worker States {CPU = 2, blocking = 1, parked = 0, retired = 0, terminated = 0}, running workers queues = [2c, 0b, 0c], global queue size = 0, Control State Workers {created = 3, blocking = 1}]], Continuation at io.ktor.http.cio.PipelineKt$startConnectionPipeline$1$outputsActor$1.invokeSuspend(Pipeline.kt:77)@7b0cac71]. Please read KDoc to 'handleFatalException' method and report this incident to maintainers
    e
    v
    • 3
    • 4
  • a

    andylamax

    07/15/2020, 5:17 PM
    👀
    👀 5
    m
    • 2
    • 1
  • s

    Slackbot

    07/16/2020, 8:59 AM
    This message was deleted.
    a
    c
    • 3
    • 2
  • a

    Alexander Minyaev

    07/16/2020, 9:31 AM
    Hello! How to retry request in
    HttpClientFeature
    after
    Exception
    ? Now, I have next code:
    override fun install(feature: ExceptionFeature, scope: HttpClient) {
                scope.sendPipeline.intercept(HttpSendPipeline.Before) {
                    for (counter in 0..2) {
                        try {
                            proceed()
                            break
                        } catch (e: IOException) {
                            println("IO Error :$counter")
                            if (counter == 2) {
                                throw e
                            }
                        }
                    }
                }
    e
    • 2
    • 2
  • r

    Rodrigo Silva

    07/16/2020, 1:09 PM
    Hello all. A noob question. I have two environments,
    development
    and
    deployment
    . How do I switch between them?
    ktor {
        development {
            port = 8091
            port = ${?DEV_PORT}
        }
        deployment {
            port = 8090
            port = ${?PORT}
        }
        application {
            modules = [ com.rjdesenvolvimento.aries.ApplicationKt.module ]
        }
    }
    m
    e
    • 3
    • 9
  • h

    hhariri

    07/17/2020, 10:18 AM
    <!here> Folks - important announcement - First off, please welcome our new blog https://blog.jetbrains.com/ktor. Secondly, we’re moving to YouTrack for features/bugs. Please read more on the blog post https://blog.jetbrains.com/ktor/2020/07/migrating-to-youtrack/
    👍 29
    j
    • 2
    • 3
  • h

    Hank

    07/17/2020, 2:40 PM
    How can I use Swagger UI with Ktor, any reference?
    n
    p
    • 3
    • 5
  • a

    Avadhut

    07/18/2020, 9:43 AM
    Hi folks, anyone have beginner friendly ktor project on github please send the link. I want to learn ktor from projects. Thanks!
    m
    • 2
    • 2
  • a

    altavir

    07/19/2020, 4:07 PM
    I am getting
    Response has already been sent
    on CIO when serving static files from resources. Is it normal?
    🇳🇴 1
    e
    • 2
    • 3
  • t

    Timur Atakishiev

    07/20/2020, 7:21 AM
    Hi all, is it any role management in ktor? Something like in Spring @hasRole or @preauthorized?
    n
    • 2
    • 1
  • a

    addamsson

    07/20/2020, 2:34 PM
    Can you point me to some good examples and/or clear documentation on how to deserialize parameters when using Ktor's
    ContentNegotiation
    feature? I've been banging my head against the wall for ours and it is still not working for me. I have parameter classes with the
    @Searializable
    annotation:
    @Serializable
    data class ShowPostURL(
            val date: String,
            val titleSlug: String,
            override val redirectTo: String? = null
    )
    and no matter what I do
    call.receive()
    won't work. I'm getting
    HTTP 415
    errors and Ktor doesn't even log anything. I've added the serialization support as well:
    install(ContentNegotiation) {
        json
    }
    How do I fix this? This is how I'm trying to use it:
    accept(ContentType.Any) {
        get(operation.route) {
            val input = call.receive(ShowPostURL::class)
            call.respondText("foo")
        }
    }
    e
    n
    • 3
    • 80
  • d

    dorf

    07/20/2020, 11:33 PM
    (cross question from coroutines) Is it a typical pattern to pass around the coroutine scope (io.ktor.application.Application object) as a parameter to my suspend functions?
    t
    • 2
    • 1
  • b

    Brendan Weinstein

    07/21/2020, 4:02 AM
    With the announcement of changing the memory model for kotlin-native in the long run, I am wondering if this has anything to do with freeze exception struggles for the iOS ktor client. Is it still in the plans for the ktor client to overcome freeze exceptions with multithreaded coroutines for the Kotlin 1.4 release?
    ➕ 1
    n
    • 2
    • 1
  • h

    Hank

    07/22/2020, 2:01 AM
    Is it possible to get a Gson instance in router functions since I’ve installed Gson module? Or I have to new it every time?
    w
    • 2
    • 2
  • a

    andylamax

    07/22/2020, 10:43 AM
    the
    CIO
    server is still experimental. And the message says, that it could be removed. Understanding that this is a generic message to all
    KtroExperimental's
    should I refrain from the
    CIO
    server and use
    Netty
    or others? Any assurance for the
    CIO
    server?
    h
    g
    k
    • 4
    • 5
  • a

    aleksey.tomin

    07/22/2020, 4:26 PM
    What do I use in 1.3.2-1.4-M3 instead of
    io.ktor:ktor-client-core-native
    ?
    e
    • 2
    • 2
  • l

    Luis Munoz

    07/23/2020, 1:14 AM
    How I get the session id in a get() {}, I just see examples of doing
    call.sessions.get<MySession>()
    but why isn't there call.sessions.getId or something?
    b
    • 2
    • 1
  • n

    Nikolai

    07/24/2020, 10:03 AM
    Hi, everyone. I have multiplatform project using ktor. And it’s working fine on Android platform. When I try to compile iOS framework I got following error :
    Task :app:compileKotlinIos
    
    w: skipping /Users/nikolaybaklanov/.gradle/caches/modules-2/files-2.1/io.ktor/ktor-client-ios-iosarm64/1.3.1/2f594cbbb3394fe255137a805e4b3f02bfcb5cae/ktor-client-ios.klib. The abi versions don't match. Expected '[22]', found '17'. The library produced by 1.3.61-release-13550 compiler
    
    e: Could not find "/Users/nikolaybaklanov/.gradle/caches/modules-2/files-2.1/io.ktor/ktor-client-ios-iosarm64/1.3.1/2f594cbbb3394fe255137a805e4b3f02bfcb5cae/ktor-client-ios.klib" in [/Users/nikolaybaklanov/Projects/OvercomingPain, /Users/nikolaybaklanov/.konan/klib, /Users/nikolaybaklanov/.konan/kotlin-native-macos-1.3.72/klib/common, /Users/nikolaybaklanov/.konan/kotlin-native-macos-1.3.72/klib/platform/ios_arm64].
    15:57:23: Task execution finished 'compileKotlinIos'.
    My build.gradle for iOS part :
    iosMain {
        dependencies {
            implementation 'org.jetbrains.kotlin:kotlin-stdlib-common:1.3.72'
            implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.8'
            implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serialization_version"
            implementation "io.ktor:ktor-client-ios:$ktor_version"
        }
    }
    
    kotlin_version=1.3.72
    coroutines_version=1.3.0
    ktor_version=1.3.1
    serialization_version=0.10.0
    j
    t
    • 3
    • 3
  • m

    manlan

    07/24/2020, 7:25 PM
    My log statements somehow do not appear in the Run dialog of Intelij. Can anyone help me know if I'm doing something wrong?
    r
    • 2
    • 2
  • t

    tylerwilson

    07/24/2020, 9:58 PM
    I am (attempting to) use Ktor for client multipart form uploading for an image. I think I every set yp okay, but I am getting extra lines between the header and body like this, which the Apache server we are using may be choking on (still gathering logs). Does this sound believable? If so, any way to fix it?
    User-Agent: Ktor client
    Content-Length: 153714
    Accept-Language: en-us
    Accept-Encoding: br, gzip, deflate
    
    
    
    --3e9d8564-2440331c-2bc8a4e3-2a59ce744dd5479a2de37096-3fd591e8-4dbb8fc5-
    Content-Disposition: form-data; name="p_comId"
    • 1
    • 2
  • h

    huehnerlady

    07/28/2020, 3:10 PM
    Hi, I am very new to the ktor client. What I am trying to do is using it for an integration test using oauth. Using the manual way to add a
    Authorization
    header manually works, but I need to automate it using clientCredentials flow and client-id and client-secret. So far when I google about it, I just get how to set up oauth with ktor on the server-side, not on the client side. Has anybody done so and can give me a code example or a link where I can find help?
    n
    • 2
    • 5
  • l

    LastExceed

    07/29/2020, 10:34 AM
    how do i read a string from a
    ByteReadChannel
    ? i know there is
    .readUTF8Line()
    but what if my string contains newlines ? do i have to convert the string to a bytearray and send that (preceded with its size) or is there a better way ?
    e
    • 2
    • 5
  • b

    bitkid

    07/29/2020, 12:03 PM
    i need to write a simple endpoint which receives a file via http and passes it on to the aws sdk transfermanager for uploading to S3. can i do it in a way that i only handle streams, so that the file is never fully read (to memory/disk). files are very, VERY big. how could i do that with ktor?
    • 1
    • 1
  • a

    anthony castillo

    07/29/2020, 2:12 PM
    Hello. We encountered a scenario with routes and interceptors that seems weird. Please consider the scenario below:
    fun Route.routeA() = route("/a") {
      intercept(ApplicationCallPipeline.Call) {
        <do_something_a>
      }
    }
    
    fun Route.routeB() = route("/a/{some_value}") {
      intercept(ApplicationCallPipeline.Call) {
        <do_something_b>
      }
    }
    
    routing {
      routeB()
      routeA()
    }
    When we send a request to
    /a/some_value
    , the request goes through
    do_something_a
    first before
    do_something_b
    . Is this the expected behavior? Our expectation is that only
    do_something_b
    would be triggered, since in this case
    routeB
    is not a child route of
    routeA
    Note: We separated the routes due to the hope that the interceptor will only be applied to the enclosing route. We have some business requirement where ACL is different on those scenarios
    b
    • 2
    • 1
  • p

    Patrick Louis

    07/30/2020, 8:18 AM
    Hello, Is there a way to disable content-negotiation before receiving a single call? The problem I'm trying to solve is that I want to write the content of the request to log if Gson throws a JsonParseException, but calling call.receiveText() from the exception handler will just result in a
    RequestReceiveAlreadyFailedException: Request body consumption was failed
    .
    • 1
    • 1
  • a

    Alexandre Brown

    07/30/2020, 5:25 PM
    Would you consider WebSocket Feature production ready and ready to handle a lot or concurrent users ex: For a mobile game ? Is it stable ?
    l
    • 2
    • 2
  • j

    John O'Reilly

    07/30/2020, 6:05 PM
    What is the current status of availability of version of
    ktor
    that works with
    native-mt
    version of koltinx coroutines?
    👍 2
    • 1
    • 1
  • s

    Sam

    07/31/2020, 3:24 AM
    Does anyone know of any open source that can build video/audio call ? I’m using Ktor and I want to implement video/audio call with this framework. Thanks
    👀 1
    j
    • 2
    • 5
Powered by Linen
Title
s

Sam

07/31/2020, 3:24 AM
Does anyone know of any open source that can build video/audio call ? I’m using Ktor and I want to implement video/audio call with this framework. Thanks
👀 1
j

Jurriaan Mous

07/31/2020, 5:59 AM
Probably it is best to look into webrtc which is available on the browser and in native client. I don’t know which platform you need it for but if it is multiple it is probably not so difficult to make a common library with expect actual implementations. http://webrtc.github.io/webrtc-org/native-code/
🎉 1
s

Sam

07/31/2020, 6:01 AM
Have you got problem to development webrtc open source on web/ios/android/flutter? Thanks.
j

Jurriaan Mous

07/31/2020, 6:06 AM
For now I only did audio/video calls with the sample apps to see how it works and read into it. It looked pretty easy. There was a NAT problem that is good to be aware of because it needs some extra server work to make like 20% of the connections go well. https://webrtchacks.com/an-intro-to-webrtcs-natfirewall-problem/
s

Sam

07/31/2020, 6:06 AM
Ohm thank you so much.
j

Jurriaan Mous

07/31/2020, 6:07 AM
At work we use a commercial solution. With that I have some more experience. But if doing it anew I would look into WebRTC.
View count: 1