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

    John O'Reilly

    11/02/2021, 5:19 PM
    I was trying out
    1.6.0-RC
    Kotlin version and when I run app (on iOS) now I'm getting
    Failed to find HttpClientEngineContainer. Consider adding [HttpClientEngine] implementation in dependencies.
    I have
    io.ktor:ktor-client-ios
    dependency (as before). https://kotlinlang.org/docs/eap.html#build-details seems to indicate that version should work with Ktor 1.6.4
    h
    a
    • 3
    • 7
  • h

    hhariri

    11/02/2021, 6:24 PM
    📣 1.6.5 Released https://twitter.com/JetBrainsKtor/status/1455600162382905345
    :kotlin-intensifies: 5
    🎉 1
    y
    j
    • 3
    • 5
  • w

    William Persall

    11/02/2021, 10:06 PM
    Can someone point me to documentation for integrating queries to DB2 into ktor. I have never worked with having to setup jdbc and the connections to a particular type of database before and would be very appreciative?
    b
    a
    • 3
    • 4
  • t

    Tomasz Krakowiak

    11/02/2021, 11:29 PM
    Is there any decent way to implement mutual SSL authentication? (Including extracting certificates' subject and other parameters)
    • 1
    • 1
  • m

    Marko Kunic

    11/03/2021, 4:34 PM
    Hello, I am using ktor client, I am wondering how can I get the response from the client without using coroutines? found some links that say to use
    runBlocking
    but still not sure how to get the response outside of it?
    h
    • 2
    • 2
  • y

    yogurtearl

    11/03/2021, 6:20 PM
    Any plans to add support HTTP/2 for CIO?
    a
    • 2
    • 1
  • m

    Marko Kunic

    11/04/2021, 9:32 AM
    I am trying to append a header to my request, documentation says it is a string, but when I pass a string I get a type mismatch:
    Type mismatch.
    Required: HeaderValueWithParameters
    Found: String
    HeaderValueWithParameters is abstract, not sure what to pass here?
    a
    • 2
    • 13
  • j

    Jeff Lockhart

    11/05/2021, 10:18 PM
    Not sure what channel this question best belongs in, but since it's with using Ktor, someone here might have some insight. I have a Ktor
    HttpClient
    and an
    Authenticator
    class I'd like to install in the client. In an effort to beautify the code, I'm trying to make the syntax concise. I'd like this to work:
    class Api(authenticator: Authenticator) {
        private val client = HttpClient {
            Auth {
                authenticator.install() // Unresolved reference: install
            }
        }
        //...
    }
    
    class Authenticator(
        private val dependency: Dependency
    ) {
    
        fun Auth.install() {
            bearer {
                //...
            }
        }
    }
    But get "Unresolved reference: install" error. It's not able to call the
    install()
    function with
    Auth
    as the receiver. If I change
    authenticator.install()
    to
    with(authenticator) { install() }
    or
    authenticator.run { install() }
    , this works, but obviously not as nice.
    Authenticator
    has dependencies, which is why the class is necessary and can't be a simple extension function. Is there a better way to format this code to achieve what I'm trying to do as concisely as possible?
    r
    • 2
    • 1
  • m

    Marcin Wisniowski

    11/07/2021, 12:55 AM
    I'm having an issue with
    ApplicationCall.respond()
    taking up to 10 seconds in some situations, how could I debug that, or what could be possible causes to look into?
    b
    a
    • 3
    • 5
  • c

    coroutinedispatcher

    11/07/2021, 2:16 PM
    Hello 🙂 I need to run a function just once a month periodically on the server (or twice a month whatever). How can I achieve this with ktor, can you just use coroutines for such big delays?
    j
    • 2
    • 3
  • r

    Rak

    11/07/2021, 2:21 PM
    Hi, I am looking to write a plugin (an interceptor in retrofit). I need to add an etag if it exists in the local db, to the request and then store the etag from the response header for use next time. Any examples of how i can achieve this? The KTor documentation is not very helpful (and has. broken link).
    a
    • 2
    • 1
  • k

    Kamo Spertsyan

    11/08/2021, 8:33 AM
    Hello! I've got weird but interesting for me question about ktor client library. Would be glad to hear developers team answers. Had you thought about giving some additional API besides coroutines one? If had but decided not to do it, then why? (I don't need different API, just want to understand your position in this question) Thank you! Looking forward for your answer.
    e
    a
    a
    • 4
    • 21
  • h

    hsyogesh

    11/08/2021, 9:19 AM
    Hello! I am using Ktor as common library for platforms iOS and Android our backend services are session and cookie based, where I first do authorization call, as response I get token, using that token as cookie header I need to make next consecutive requests for which ktor client is adding encoded value instead of actually passed value for which my backend is not providing valid response, can anyone help me in resolving this, upon verifying using proxy tools, if my backend is expecting token = LYJxQGo1pgmP_Eu-tAMmcA..|1636367566|ckC8hI-v1vj1KIz_4CDKupRDUhk., ktor is passing LYJxQGo1pgmP_Eu-tAMmcA..%2%2%21636367566|ckC8hI-v1vj1KIz_4CDKupRDU
    a
    • 2
    • 9
  • a

    altavir

    11/08/2021, 9:51 AM
    @Ovsyannikov Alexey just found a nasty bug in the latest KTor: https://youtrack.jetbrains.com/issue/KTOR-3380. It is caused by inconsistency between target JDK version and the actual JDK used for the build.
    🙏 2
    a
    • 2
    • 1
  • m

    Marcelus Trojahn

    11/08/2021, 11:01 PM
    Hello all, what would be the best approach to add validation to data classes that are used as endpoint schemas? Right now I'm using protobuf and creating my own serializers... But that gets out of hand very easily.
    m
    b
    +2
    • 5
    • 12
  • m

    Marcello Galhardo

    11/10/2021, 2:26 PM
    Hi there, I’m not sure if that is the right channel to ask that: I’m using Ktor Http Client and I need to add a dynamic header in all calls based on some conditions. With Retrofit I would normally add a simple interceptor and that would be the trick - but looking the docs I did not find a way to add interceptors when doing requests with Ktor (I’m finding very confusing Ktor docs, probably because I’m trying to find things for the client and I end up reading about the server and vice-verse). Can someone point me to examples on how to do that?
    a
    • 2
    • 2
  • t

    Timur Atakishiev

    11/11/2021, 8:23 AM
    hey guys! is it any tutorial how to use integration tests with test containers in ktor?
    a
    k
    • 3
    • 8
  • a

    Alex Styl

    11/11/2021, 8:55 AM
    I use the html DSL to return html on requests on my ktor server. Right now I have a mix of kotlin html and it links to javascript files (similar to how you would have in a plain old html). I noticed that there is a kotlin/js wrapper (?). Is it somehow possible to use kotlin 100% and get rid of the javascript files entirely?
    a
    • 2
    • 3
  • a

    Arnab

    11/11/2021, 1:09 PM
    Hey there! If I have a ktor client and some sealed class
    Foo
    that has
    Bar
    and
    Baz
    as subclasses, and I make a post request that can either create a
    Bar
    or a
    Baz
    , how can I do that? Do I say
    <http://myClient.post|myClient.post><Foo> { … }
    and then process the entity as either
    Bar
    or
    Baz
    ?
    a
    d
    • 3
    • 4
  • j

    Joost Klitsie

    11/11/2021, 3:52 PM
    Hi all! Is there somewhere some in depth information about routes and phases? I made once a feature that could "override" a security rule/role for a route. It can override it, by adding phases to a pipeline in reverse order. In eap 2.0-256 the behavior seems a bit different than older version, more in the thread.
    r
    • 2
    • 3
  • c

    Cristian Rosa

    11/11/2021, 4:14 PM
    Does anyone know (or had faced the problem) when I “runDistributable” (or the app from the file generated buy intellij) I got this error:
    Failed to instantiate SLF4J LoggerFactory
    Reported exception:
    java.lang.NoClassDefFoundError: javax/naming/NamingException
    The weird thing is if I run the app throw the IDE or with a jar by command line no error and everything works as expected the module where I got the error is a pretty simple ktor server (with some client part to talk to a master-server) a very simple views written in compose
    • 1
    • 1
  • a

    Angad

    11/11/2021, 6:36 PM
    Hi, I am currently doing performance benchmark of a KMM project. Although there were no memory leaks in the Android App for one of the flows, But there are a plenty of leaks in the iOS app. After implementing one of the solutions mention in this issue (ie. calling 
    kotlin.native.internal.GC.collect()
     when screens are getting closed) the leaks exist. I'm sharing screenshots for some of the memory leaks. Has anyone else seen these kind of leaks before?
    👀 2
    :thread-please: 1
    • 1
    • 1
  • p

    Philip Dukhov

    11/12/2021, 5:15 AM
    I'm writing a KMM app and I'd like to share Ktor routes between server and client. Right now I'm using string for route names:
    // server
    route("user") {
        post("setFavorite") {
            
        }
    }
    route("auth") {
        post("facebook") {
            
        }
    }
    route("other") {
    
    }
    // client
    <http://client.post|client.post><Unit>("/user/setFavorite")
    I'd like to share this names to prevent errors. For example with interface like this:
    sealed interface ServerRoutes {
        sealed interface User: ServerRoutes {
            object SetFavorite: User
        }
        sealed interface Auth: ServerRoutes {
            object Facebook: Auth
        }
        object Other: ServerRoutes
    }
    Which could be used like this:
    // server
    route(ServerRoutes.User) {
        post(ServerRoutes.User.SetFavorite) {
            
        }
    }
    route(ServerRoutes.Auth) {
        post(ServerRoutes.Auth.Facebook) {
            
        }
    }
    route(ServerRoutes.Other) {
    
    }
    // client
    <http://client.post|client.post><Unit>(ServerRoutes.User.SetFavorite)
    I think I can generate routes from class names using annotation processor, but I'm wondering if there's some existing solution?
    h
    a
    • 3
    • 3
  • p

    Paul Woitaschek

    11/12/2021, 8:10 AM
    Its seems that the publish infrastructure is broken again https://search.maven.org/artifact/io.ktor/ktor-client-core-watchosx64/1.6.5 Wasn't published
    :tnx: 1
    👀 2
    e
    • 2
    • 7
  • l

    Lukasz Kalnik

    11/13/2021, 6:25 PM
    How can I make client logging work in a multiplatform (Android/iOS) project? I have set up logging in my shared code:
    internal fun createHttpClient() = HttpClient {
                install(Logging) {
                    logger = Logger.DEFAULT
                    level = LogLevel.ALL
                }
            }
    but I see no logs. On Android I use the CIO client.
    a
    • 2
    • 1
  • j

    Justin

    11/13/2021, 7:23 PM
    Is there an example anywhere of using Ktor Server (EAP) in a Kotlin Multiplatform project that targets K/N (macOS/iOS)? I see that the artifacts for
    ktor-server-core
    and
    ktor-server-cio
    exist in maven (e.g. https://maven.pkg.jetbrains.space/public/p/ktor/eap/io/ktor/ktor-server-core-macosarm64/) but I can't seem to figure out how to configure my build.gradle.kts to get the right dependencies (a lot of dependency could not be found errors regardless of which version of the EAP I target).
    e
    s
    • 3
    • 2
  • n

    nordiauwu

    11/13/2021, 7:55 PM
    I need to stream a relatively large file (300-500 MB) concurrently to 10+ clients, but under load, the download speed gets super low (down to 300 kb/s). It feels like the server doesn't have enough resources to process such amount of long-running requests 🤔 Environment: OS: Windows 10 x64 CPU: Intel Core i9-10900k RAM: 32 GB Code:
    fun main() {
        val file = File("G:/test.zip")
    
        embeddedServer(CIO, port = 8081) {
            routing {
                get("/file") {
                    call.response.header(HttpHeaders.ContentDisposition, "inline; filename=\"test.zip\"")
    
                    call.respondOutputStream {
                        file.inputStream().buffered().use { stream -> stream.copyTo(this.buffered()) }
                    }
                }
            }
        }.start(true)
    }
    So what is a good way to debug it? Or maybe there is a better approach I can use?
    e
    a
    • 3
    • 5
  • g

    Gabi

    11/14/2021, 12:08 AM
    hey! how i can create a bytepacketbuilder with custom capacity with ktor io?
    a
    • 2
    • 6
  • j

    Javier

    11/15/2021, 11:24 PM
    is there ktor client for watchos, tvos and so on? I am checking there is one for iOS but I can't find if it works with rest of targets
    t
    a
    • 3
    • 2
  • s

    saket

    11/16/2021, 3:33 AM
    jetbrains folks, please consider publishing eap builds of ktor with kotlin 1.5.31 so that we can start using it in existing projects? using an unstable version of kotlin (that is, 1.6.x) is painful in kmp.
    e
    • 2
    • 3
Powered by Linen
Title
s

saket

11/16/2021, 3:33 AM
jetbrains folks, please consider publishing eap builds of ktor with kotlin 1.5.31 so that we can start using it in existing projects? using an unstable version of kotlin (that is, 1.6.x) is painful in kmp.
e

ESchouten

11/16/2021, 6:20 AM
You could use 1.6.0 stable right now
s

saket

11/16/2021, 6:23 AM
I wanna use 2.0.0-eap to try out ktor server on k/native
e

ESchouten

11/16/2021, 6:33 AM
I understand, I am using Kotlin 1.6.0 stable with Ktor 2.0.0 EAP myself. Released two days ago. https://github.com/ESchouten/KtorNativeServer
View count: 1