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

    spierce7

    08/21/2019, 4:29 PM
    What’s the standard way to return a 400 response when there is an error deserializing Json? Wrapping each body deserialization with a try/catch, looking for
    kotlinx.serialization.json.JsonParsingException
    , or using an equivalent extension function seems error prone and verbose. Surely there is a way to do this at the feature level?
    z
    • 2
    • 2
  • a

    anli

    08/22/2019, 10:37 AM
    On using ktor client and getting 409 I get ClientRequestException on attempt to read a body with
    response.readText()
    . On the other hand it is official recommendation for 409 response to get payload. How to get the payload with ktor?
    d
    • 2
    • 1
  • u

    4ntoine

    08/23/2019, 10:58 AM
    I’m trying to compile K/N project with just released
    1.3.50
    and ktor and having ABI incompatibility (worked with
    1.3.41
    ):
    w: skipping /Users/asmirnov/.gradle/caches/modules-2/files-2.1/io.ktor/ktor-client-core-macosx64/1.2.3/4987d836935e25e127e275b7147fa24ff9b24b1b/ktor-client-core.klib. The abi versions don’t match. Expected ‘[14]’, found ‘9’
    w: The compiler versions don’t match either. Expected ‘[]’, found ‘1.3-rc1-11132’
    e: Could not find “/Users/asmirnov/.gradle/caches/modules-2/files-2.1/io.ktor/ktor-client-core-macosx64/1.2.3/4987d836935e25e127e275b7147fa24ff9b24b1b/ktor-client-core.klib” in [/Users/asmirnov/Documents/dev/src/cmp/project/desktop/performance_app, /Users/asmirnov/.konan/klib, /Users/asmirnov/.konan/kotlin-native-macos-1.3.50/klib/common, /Users/asmirnov/.konan/kotlin-native-macos-1.3.50/klib/platform/macos_x64].
    Anyone? As far as i can see Ktor 1.2.3 is not yet released for 1.3.50 and the most recent one is https://mvnrepository.com/artifact/io.ktor/ktor-client-core/1.2.3-1.3.50-eap-5
    c
    r
    t
    • 4
    • 12
  • l

    Leon K

    08/23/2019, 6:36 PM
    is there any kind of arrow-kt integration for Ktor (specifically Ktor-client stuff)? Currently im using extension functions on HttpClient like
    getSafe
    that just wrap the
    HttpClient.get
    method in a `Try`object, but i wonder if there is any way to get that out of the box / with a library
    d
    • 2
    • 4
  • c

    coder82

    08/26/2019, 9:48 AM
    Hi guys, in the KTOR documentation there is no info about coroutine scoping, in essence what's the scope the call is run into, what if I launch a coroutine within a call and then the whole call is timedout? will the parent cancel it? @cy I ask because I am afraid my coroutines will leak if I don't pay attention to this, even though I always try to fork everything on the context of the parent call, not global! @e5l
    d
    d
    • 3
    • 2
  • s

    Shan

    08/27/2019, 3:13 AM
    Hey all. Does anyone know what the minimum Android SDK version supported for the CIO engine is?
    c
    • 2
    • 1
  • d

    darkmoon_uk

    08/27/2019, 7:47 AM
    Any news on a
    1.3.50
    -based Ktor 'update' release? 🤞 :kotlin-flag:
    👀 2
    • 1
    • 1
  • s

    snackycracky

    08/27/2019, 8:25 AM
    Hey 🙂 what is the “official” way to autogenerate OpenAPI or Swagger specs in ktor ?
    ➕ 1
    b
    b
    • 3
    • 16
  • f

    Fail

    08/27/2019, 8:52 AM
    Can I add body to DELETE request?
    b
    b
    s
    • 4
    • 10
  • e

    Evgeniy Zaharov

    08/27/2019, 4:11 PM
    Hi. Does
    ktor
    have any plans in future to implement a huge customization futures like
    spring
    project have? For example in spring exist inner DI with which you could in next configuration steps retrieve some bean from previous. Or in runtime replace any bean in context by creating it by yourself. For now ktor doesn’t contain any DI system internal and such cases is difficult to implement without it. And for now I couldn’t imagine how to implement something like spring starters which are comes with new beans inserting to context + bean post processors which could customize beans depends on conditions/previous creatated beans/etc. I don’t say that
    ktor
    is going by wrong way or what it’s had some invalid architecture constructions. Me really likes how it constructs internal. And I just want to know, is at ever possible to do something like in spring for ktor?
    k
    g
    • 3
    • 5
  • b

    bram93

    08/28/2019, 7:55 AM
    Hi all, could someone tell me how I can intercept after the authentication feature pipeline has been finished? I want to load an user profile after being logged in
    m
    e
    v
    • 4
    • 27
  • c

    coder82

    08/28/2019, 8:28 AM
    When I intercept ApplicationCallPipeline.Fallback, I cannot access the response message of my response, only the status, any reason why?
    r
    • 2
    • 4
  • s

    snackycracky

    08/28/2019, 8:39 AM
    Hey 🙂 I am getting
    java.io.IOException: Connection reset by peer
    from Netty for all my requests that were answered with a 200. I understand that the client closed the connection, but why is then an exception thrown? Did somebody experience this before ?
    s
    s
    • 3
    • 3
  • g

    gotoOla

    08/28/2019, 2:37 PM
    https://kotlinlang.slack.com/archives/C0A974TJ9/p1566853984325300 Anybody doing this or knows if it’s possible?
    s
    • 2
    • 6
  • t

    tjohnn

    08/29/2019, 4:05 AM
    I am having issues with docker containerized application, it is not creating sessions and throws
    java.util.NoSuchElementException: No session data found for id b8130c2077351466
    , it works fine without containerizing it. Also, I am new to docker . Is there something I need to do that I am missing?
    r
    • 2
    • 12
  • e

    eirikb

    08/29/2019, 9:59 AM
    How do I use MockEngine (https://ktor.io/clients/http-client/testing.html)? I can see how I can set it up, but I have a class with a private
    HttpClient
    d
    • 2
    • 5
  • t

    Tony Blundell

    08/29/2019, 11:05 AM
    Hi, is there any way to pass a cert when making a request with Ktor Client? Something like…
    # python requests lib
            url = '<https://example.com>'
            headers = {
                'Content-Type': 'application/x-www-form-urlencoded'
            }
            cert = (path_to_cert_file, path_to_key_file)
            data = {
                'username': username,
                'password': password
            }
            r = <http://requests.post|requests.post>(url, headers=headers, cert=cert, data=data)
    e
    • 2
    • 4
  • j

    Jan Stoltman

    08/29/2019, 1:33 PM
    Hey, I would like to use ktor to connect to an api which uses self-signed SSL certificate. I've figured out how to achieve this with
    OkHttp
    on Android, but is there any way to achieve this with the
    Ios
    engine on iOS as well?
    • 1
    • 1
  • l

    Ludd

    08/29/2019, 1:44 PM
    Hi, is there a way in ktor to close HTTP connection with client from server after responding to a post request? Cause a client seems to be keeping connection alive without reusing it.
    e
    • 2
    • 3
  • j

    Jeremy

    08/29/2019, 3:05 PM
    Is Ktor client (iOS) supported with worker.execute? The following code will freeze on iOS. Issue 678 describes the same issue and closed without resolution
    e
    • 2
    • 3
  • p

    Pere Casafont

    08/30/2019, 9:10 AM
    hello there, I'm using ktor websockets with netty and getting the following stacktrace (thread):
    • 1
    • 2
  • b

    bitkid

    08/30/2019, 11:44 AM
    hi! how can i tell the http client to allow a string as body when content-type = application/json? as soon as i set that header i get the exception "class java.lang.String cannot be cast to class io.ktor.client.call.HttpClientCall"
    d
    • 2
    • 22
  • t

    Thomas

    08/30/2019, 1:06 PM
    Hello, I was wondering if someone from Ktor is looking into the following issue. I would really like a solution for this. If anyone has any suggestions how I could fix this, please let me know. https://github.com/ktorio/ktor/issues/1263
    ➕ 2
    e
    v
    +2
    • 5
    • 60
  • b

    bitkid

    08/31/2019, 12:29 PM
    hi! anyone experience this exception when using the Apache HTTP client? java.lang.IllegalStateException: Unexpected request state READY
    • 1
    • 6
  • r

    Robin Larsen

    08/31/2019, 9:09 PM
    I'm having a hard time understanding when to use the
    handle
    method in a
    Route
    . My initial thought was that it is a place to put a piece of code that should execute every time the route is triggered - could be checking a cookie for relevant info and reacting accordingly. But it doesn't seem to work that way. Can anyone shed some light on this one please 🙂
    s
    • 2
    • 1
  • i

    Ingo Noka

    09/02/2019, 6:25 AM
    1. Context + I am connecting from a client with Ktor version 1.2.3 raw socket with TLS to the TCP Input Plugin Version v6.0.3 with Logstash 7.3. 2. Issue + TLS/SSL negotiation fails and I am getting a
    TLSException
    with error message +
    Unknown hash algorithm: 8
    3. Analysis: - The accuracy of all key and certificate files confirmed with successful openssl: +
    openssl s_client -connect IP:PORT -CAfile cacert.pem -cert client_crt.pem -key client_key.pem
    - The output of
    openssl
    gives a hint at what might be wrong: + [source,subs="quotes"] .Requested Signature Algorithms:
    ECDSA+SHA256:**0x04+0x08**:RSA+SHA256:ECDSA+SHA384:**0x05+0x08**:RSA+SHA384:**0x06+0x08**:RSA+SHA512:RSA+SHA1
    + .Shared Requested Signature Algorithms: ---- ECDSA+SHA256:RSA+SHA256:ECDSA+SHA384:RSA+SHA384:RSA+SHA512:RSA+SHA1 ---- - I assume that the requested signature algorithms come from the server and include hash code 0x08 (as in
    0x04+0x08
    ) - I also assume that the
    0x08
    hash code comes from the new "Intrinsic" hash hash code introduced in RFC 8442 and registered by IANA [https://www.iana.org/assignments/tls-parameters/tls-parameters.txt] - Looking into the source code of the TLS handshake routines of ktor-network-tls I find in
    io/ktor/network/tls/extensions/SignatureAlgorithm.kt
    the following snippet: +
    kotlin
    enum class HashAlgorithm(val code: Byte, val openSSLName: String, val macName: String) {
        NONE(0, "", ""),
        MD5(1, "MD5", "HmacMD5"),
        SHA1(2, "SHA-1", "HmacSHA1"),
        SHA224(3, "SHA-224", "HmacSHA224"),
        SHA256(4, "SHA-256", "HmacSHA256"),
        SHA384(5, "SHA-384", "HmacSHA384"),
        SHA512(6, "SHA-512", "HmacSHA512");
    
        companion object {
            /**
             * Find hash algorithm instance by it's numeric [code]
             * @throws TLSExtension if no hash algorithm found by code
             */
            fun byCode(code: Byte): HashAlgorithm = values().find { it.code == code }
                ?: throw TLSException("Unknown hash algorithm: $code")
        }
    }
    - It seems to me that throwing an exception when encountering an unknown hash algorithm is not necessary. The algorithm would be ignored anyway when the list of mutually supported algorithms is build. Questions: . Is my analysis correct? . Should I file an issue for ktor on Github and propose the following change options: .. Add
    INTRINSIC(8, "INTRINIC", "Intrinsic")
    to the
    HashAlgorithm
    enum class .. Change the return type of
    byCode()
    to a nullable and ignore null when building the list of requested hash algorithms . Is there a way to prevent a ruby.openssl based server (not ktor) from sending the new hash code value 8? (Please ignore this question if it does not belong to ktor|kotlinlang)
    e
    • 2
    • 7
  • g

    gumil

    09/02/2019, 7:50 AM
    Hello, I am an Android Developer, trying to learn backend development using ktor. Are there open source projects that uses ktor? I want to know the common stack/libraries used together with ktor.
    t
    r
    • 3
    • 6
  • c

    coder82

    09/02/2019, 8:43 AM
    I am updating ktor but something changed here:
    r
    • 2
    • 5
  • a

    Aalok

    09/02/2019, 10:51 AM
    Hey guys, new to Kotlin and this channel, please help me. Basically I'm facing this issue. https://github.com/ktorio/ktor/issues/253 I'm not able to read from application.conf file, please help
    e
    e
    c
    • 4
    • 3
  • m

    martin.petrulak

    09/02/2019, 1:21 PM
    Hey Guys, i have a performance question that is not directly related to K-Tor, but since i am building my backend & clients using ktor/multiplatform i will ask it here (i am primally an android dev). I have a bigger data set around 15 000 entries, the whole set is around 20 MB in MySQL and i was experimenting a bit with the performance tuning when i want to get one element. My assumption was that if i cache the collection in
    HashMap<Long,MyObject>
    and don't access the DB all the time i will get faster response times, but i did not . It takes more time to execute the request if i add this "cache (hash map)" there. Is it fine to use mysql only, since it contains some sort of caching?
    r
    • 2
    • 2
Powered by Linen
Title
m

martin.petrulak

09/02/2019, 1:21 PM
Hey Guys, i have a performance question that is not directly related to K-Tor, but since i am building my backend & clients using ktor/multiplatform i will ask it here (i am primally an android dev). I have a bigger data set around 15 000 entries, the whole set is around 20 MB in MySQL and i was experimenting a bit with the performance tuning when i want to get one element. My assumption was that if i cache the collection in
HashMap<Long,MyObject>
and don't access the DB all the time i will get faster response times, but i did not . It takes more time to execute the request if i add this "cache (hash map)" there. Is it fine to use mysql only, since it contains some sort of caching?
r

Robert Menke

09/02/2019, 1:52 PM
MySQL will handle 15,000 records just fine. In fact, it can handle millions of records just fine. This is more of a data structures question than a ktor question. Hashmaps have an O(1) lookup speed, lookups in mysql on an indexed field have O(log(N)) lookup speed because MySQL organizes indexes using a Btree, and unindexed fields have an O(N) lookup time typically because the engine has to iterate over the entire data set. In short, I would not recommend adding your own caching for 15,000 records. Furthermore caching via a hashmap is the wrong approach. You want your server to be stateless so that your app can scale to multiple servers. Once you need caching, reach for something like memcache or redis.
🍻 1
👍 2
m

martin.petrulak

09/02/2019, 1:57 PM
@Robert Menke thank you. Makes sense 🙂
👍 1
View count: 2