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

    ivano

    12/31/2019, 5:47 PM
    I write here because came another intervention. Sorry but I do not get what you guys mean. I tried to run on the internet a research about 'Ktor vs Springs', or 'limit of Ktor' and what i get is that is a microframework ktor, that means that lacks some advanced features. But if becomes popular will come more and more libraries right? And for what concern legacy code, can be also integrated in existing Spring project with a different stack that communicates with Spring right?
    a
    b
    m
    • 4
    • 6
  • t

    Tony

    01/01/2020, 4:39 PM
    Since KotlinxSerializer setMapper is deprecated, what should be used instead?
    d
    c
    • 3
    • 5
  • m

    mbonnin

    01/02/2020, 9:49 PM
    When installing
    Logging
    (https://ktor.io/clients/http-client/features/logging.html) alongside other features that can change headers in a client, does the order matter ? Can I make sure to always get what's transmitted over the wire ?
    l
    • 2
    • 2
  • c

    codec

    01/03/2020, 1:54 AM
    But once you import //https://mvnrepository.com/artifact/org.webjars.npm/material-components-web It’s not exactly clear how to setup the static resource to use those css and js files.
    c
    • 2
    • 5
  • j

    jlleitschuh

    01/03/2020, 4:13 AM
    Does Ktor CIO implement request pipelining? IE, reusing the same connection for multiple requests? If so, I think I may have another vulnerability in Ktor.
    c
    • 2
    • 10
  • s

    Sabeeh

    01/03/2020, 9:00 AM
    ktor version
    1.3.0-rc2
    in post call when call function
    call.receiveParamters()
    i get this error
    java.lang.NoSuchMethodError: 'java.lang.Object io.ktor.request.ApplicationReceiveFunctionsKt.receive(io.ktor.application.ApplicationCall, kotlin.reflect.KType, kotlin.coroutines.Continuation)'
    Any idea how fix it? it work fine if using ktor version
    1.2.2
    @hhariri
    c
    • 2
    • 4
  • t

    Thiyagu

    01/03/2020, 1:02 PM
    Hey all, sorry for spamming.. may be vague question for the larger audience. anyone give me why ktor is best bet when writing REST api in kotlin?
    c
    d
    g
    • 4
    • 3
  • c

    cy

    01/03/2020, 3:15 PM
    readUntilDelimiter should do the trick
    r
    • 2
    • 3
  • m

    melatonina

    01/04/2020, 9:53 AM
    I can't import class io.ktor.auth.AuthenticationProvider and other classes for ktor, even if I can run a ktor application. Why is it so? Do I need to reference some other dependency? The whole io.ktor.auth package is not available.
    d
    v
    • 3
    • 7
  • m

    Marcin Wisniowski

    01/05/2020, 12:45 AM
    Hello, how would I go about measuring response times? Let's say I want to
    println
    something like "responded to /some/endpoint in 50ms" for every request. I have found I can access every request with
    intercept(ApplicationCallPipeline.Monitoring){ /**/ }
    but I'd like to access every response before it's sent and some information about it.
    d
    • 2
    • 3
  • b

    bod

    01/05/2020, 6:36 PM
    Hello, World! I have a client library using Ktor HttpClient, and a sample on the JVM works perfectly, while the exact same code on Native (MacOS) fails with:
    Uncaught Kotlin exception: io.ktor.client.call.NoTransformationFoundException: No transformation found: class <http://io.ktor.utils.io|io.ktor.utils.io>.ByteChannelNative -> class org.jraf.klibqonto.internal.api.model.organizations.ApiOrganizationEnvelope
    So I'm supposing the problem would have something to do with the Engine that's used (I use curl on MacOS). Any idea what the problem could be?
    • 1
    • 2
  • j

    Jamie Craane

    01/05/2020, 8:23 PM
    I am looking into Ktor interceptors (from a Ktor server perspective) to modify the original response before it is send to the client. A quick example of what I want to achieve: suppose I have a route which returns some response, for example:
    route {
        get("sample") {
            call.respondText("Hello {Name}")
        }
    }
    And I want to use a global interceptor to replace the {Name} variable in the response with some other value. How do I access the contents of the response in an interceptor? (I know how I can send a custom response but not yet how I can access the original response, and modify it)
    • 1
    • 1
  • n

    nrobi

    01/06/2020, 11:30 AM
    Hey! I’m trying to deploy my
    Ktor
    backend module from a
    KMP
    project to Heroku, but I’m getting
    A problem occurred configuring project ':app'.  > kotlin.KotlinNullPointerException (no error message)
    for
    Task :buildSrc:build
    . Anyone who had similar issues?
    a
    • 2
    • 3
  • t

    Timur Atakishiev

    01/06/2020, 4:33 PM
    Hi guys! I am trying to implement simple crud in ktor and can not find any validations, something like javax.validation. Is it something existing i ktor? Or should I write my own?
    t
    z
    • 3
    • 2
  • r

    Robert Menke

    01/07/2020, 7:20 PM
    We have a ktor back-end running in AWS ECS running on top of about 8 EC2 instances. It currently handles somewhere in the neighborhood of 1.5 million requests per day and has had some serious performance issues. This ktor server replaced a single PHP server that was handling the same load and while that server was larger, it didn’t have any of the autoscaling that our ktor servers have built in and handled the load just fine. The ktor server objectively has more computing resources to work with. This app doesn’t do any heavy-duty processing. It receives requests from clients, does some database queries, and sends http requests. If you were trying to optimize this code, where might you start looking? CC @Derek Seroky
    ➕ 1
    e
    d
    • 3
    • 5
  • a

    Alan Pierri

    01/07/2020, 8:46 PM
    Hi! Any good tutorial on how to make our own interceptors? I feel dumb trying to read other's and not understanding why it works.
    c
    • 2
    • 2
  • s

    spand

    01/08/2020, 9:07 AM
    Website says:
    There is a performance penalty when using auto-reloading. So keep in mind that you should not use it in production or when doing benchmarks.
    What exactly would cause a penalty here? Simply a non empty watchPaths, or watchPaths pointing to empty directories, or using reload instead of redeploy ?
    c
    • 2
    • 5
  • p

    paulex

    01/08/2020, 10:02 AM
    override fun modify(item: User): CompletionStage<User> {
        return supplyAsync {
            transaction {
                Users.update({ Users.id eq item.id }) {
                    it[name] = item.name
                    it[gender] = item.gender
                    it[first_name] = item.firstName;
                }
            }
        }.thenApply { return@thenApply item }
    }
    Is there a way to simplify an update transaction on object properties, i feel it is repetitive to keep on writing : it[name] = item.name it[gender] = item.gender ?
    s
    • 2
    • 2
  • t

    Thiyagu

    01/09/2020, 1:48 PM
    Hey All, Anyone used
    aws paramstore
    storing the config value and resolving at runtime at the application start?
    b
    a
    • 3
    • 7
  • s

    spierce7

    01/10/2020, 3:05 PM
    When you have a Ktor server watching class files for hot-reloads, what’s the best way to re-compile class files in the IDE. If you use a gradle IDE configuration, that seems to be equivalent to using gradle from the terminal, which takes additional time because gradle has to perform startup. How do I leverage the already started daemon that the IDE owns? All means to do that seem to involve providing a main class.
    c
    • 2
    • 2
  • k

    Kris Wong

    01/10/2020, 10:46 PM
    oi... are you all aware that you can only use the ktor client from the main thread for native targets?
    b
    n
    • 3
    • 46
  • m

    MrPowerGamerBR

    01/12/2020, 6:33 PM
    I'm not sure but... I think ktor client (Apache) is leaking TextContent objects for some reason? My app crashed and when looking at the memory dump there are 654 TextContent objects, in total they are using almost 4GBs (!) The engine is created with timeouts, so it isn't leaking because the connection never succeeds.
    this.socketTimeout = 25_000
    			this.connectTimeout = 25_000
    			this.connectionRequestTimeout = 25_000
    c
    d
    a
    • 4
    • 6
  • k

    Kris Wong

    01/13/2020, 9:23 PM
    My unit test code would be a whole lot simpler if the
    MockClientEngine
    request handling could be updated after the object is created
    l
    • 2
    • 1
  • a

    anthony castillo

    01/14/2020, 12:11 AM
    Hello. Is there a way to make the HttpClient JsonFeature reuse the same serializer/mapper we have configured for the server?
    d
    • 2
    • 7
  • k

    Kris Wong

    01/14/2020, 9:57 PM
    let's say I am using HttpClient w/ serialization, and I want to handle the case of invalid JSON by getting the response text. is that possible, or do I need to receive the response as text and deserialize manually?
    d
    • 2
    • 8
  • k

    Kris Wong

    01/14/2020, 11:17 PM
    i seem to be experiencing a deadlock in
    <http://HttpClient.post|HttpClient.post>
    on iOS. the method never returns. it's called from within a
    runBlocking
    block from the main thread (from a unit test). has anyone experienced this?
    c
    e
    • 3
    • 8
  • c

    cy

    01/15/2020, 6:40 AM
    📣 ktor 1.3.0 has been released! • ktor client proxy support • Introduced
    HttpStatement
    and deprecated potentially dangerous resource-leaking client API • Eliminated kotlinx.io dependency • Fixed server identity compression handling: keep original content length • Fixed handling GET requests with body (#1302) • Fixed curl request with empty body • Added iOS url session configuration • Fixed CIO engine no longer sends port in “Host” header (#1295) • Add INTRINSIC value to TLS signature algorithms • Introduced ability to send string in request body • Improved client and server typeOf support with kotlinx.serialization • Gradle 5.4.1+ with newer metadata (metadata 1.0) • Improved exceptions handling in client and server on Android • Added missing TLS parameters and relaxed TLS parsing to ignore unsupported features • Improved session diagnostics (#1368) • Fixed
    hookRequests
    in test engine (#1300) • Deprecate java.time related API and related cleanup (for future kotlin.time support) • Restricted CIO HTTP headers parser • Introduced header name and value validation • Fixed must-revalidate on the request side in ktor client (#1406) • Fixed OkHttp client resource cleanup on close • Added watchos/tvos native targets • Fixed content truncation at native and JS targets • Fixed server’s
    If-Range
    header parsing to avoid crash at date parsing (#1377) • Fixed server’s conditional headers processing • Reduced required JDK version for
    DefaultHeaders
    server feature • Fixed client hanging due to exception in response pipeline • Replaced HttpClientJvmEngine to HttpClientEngineBase that is now common for all platforms (affects only custom client engines) • Fixed hierarchy of execution and call contexts in clients that allows to properly handle request lifetime using execution context. • Optimize JS module import time (#1464) • Upgraded versions of Netty, Jetty and Tomcat implementations • Added Pebble template engine (#1374) • Introduced localPort route that is always tied to actual socket port (#1392) • Fixed cookie expiration date parsing (#1390) • Server authentication feature’s phases are now public (#1160) • Fixed auth header resending after redirect (#1467) • TCP half-close made optional for CIO client engine and disabled by default. • Apache client random timeouts fixed • Fixed locale-dependant code (#1491) • Fixed unclosed websocket channels if cancelled too early • TCP half-close made optional for CIO client engine and disabled by default. (#1456) • Improved ktor-client-mock engine to be thread safe (#1505) • Fixed client cookies logging (#1506) • Fixed multiple application stop events in test engine (#1498) • Fixed CIO ActorSelectorManager to not spin due to cancelled keys (affects both CIO client and server) • Made default auth validate functions fail to force users to implement them • Introduced test client instance in the test server • Fixed various server and client engines to return
    null
    for missing headers rather than empty list • Introduced support for json structures in client and server (#1519) • Introduced ktor-server-core binary compatibility tracking • kotlinx.coroutines 1.3.3 See migration guide: https://ktor.io/quickstart/migration/1.3.0.html Known issues: • Netty HTTP/2 push sometimes get broken • Running ios and native client engine on non-main worker is still not supported (there are only few working scenarios so not guaranteed to work)
    👍🏼 1
    🎉 30
    👍 3
    r
    r
    • 3
    • 3
  • h

    hooliooo

    01/15/2020, 12:35 PM
    I’m currently in the process of upgrading to ktor 1.3 and I have this issue with where previously
    readRemaining()
    did not need arguments, now it needs a limit and headerSizeHint. What would be appropriate values here?
    c
    r
    • 3
    • 5
  • s

    Slackbot

    01/16/2020, 9:04 AM
    This message was deleted.
    m
    g
    j
    • 4
    • 4
  • k

    Kris Wong

    01/16/2020, 4:18 PM
    An error occurred communicating with http://localhost:8080/validate: Failed to parse request body: request body length should be specified, chunked transfer encoding should be used or keep-alive should be disabled (connection: close) CIO client engine running on an Android emulator. Server side is Ktor Netty engine.
    c
    • 2
    • 3
Powered by Linen
Title
k

Kris Wong

01/16/2020, 4:18 PM
An error occurred communicating with http://localhost:8080/validate: Failed to parse request body: request body length should be specified, chunked transfer encoding should be used or keep-alive should be disabled (connection: close) CIO client engine running on an Android emulator. Server side is Ktor Netty engine.
c

cy

01/16/2020, 4:27 PM
Looks like the response was corrupted somehow. There is a known issue that is still not reproduced when headers get corrupted on Android
k

Kris Wong

01/16/2020, 4:29 PM
it works fine running with java, for instance in my unit tests
i guess i'll have to convert my java target to an Android target so I can use one of the Android engines
View count: 9