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

    mp

    10/24/2018, 6:17 PM
    Moving to its own thread... beta 2 seems to deplete entropy very quickly, causing pretty severe blocking. Stack traces forthcoming...
    • 1
    • 2
  • l

    legzo

    10/25/2018, 11:35 AM
    Hi guys, I'm trying to create a simple logging Feature around client calls (using Apache as engine) I looked into JsonFeature and HttpPlainText as inspiration, and managed to log output requests bodies (if present) and input responses. But, logging the responses consumes the stream, and I have no clue about how to write again the raw content to the response, for the following features (such as Json serialization..) as the HttpResponse.content is a ByteReadChannel (so readonly..)
    e
    j
    • 3
    • 24
  • l

    lukaswelte

    10/25/2018, 2:40 PM
    I’m using ktor 0.9.5's CIO HttpClient to make HTTP calls to other services (so ktor server receives http requests and makes an http request to other services). On my local machine, the http request responds like it should. But on AWS (where it worked with 0.9.3) it never returns. Does somebody have an idea where the problem might be?
    d
    e
    • 3
    • 11
  • j

    jcechace

    10/25/2018, 4:13 PM
    How should I get more info from a ktor-client error, other than this?
    io.ktor.client.features.BadResponseStatus: null
    ?
    client.put<Unit>{
                url("<http://host.com/apis>")
                contentType(ContentType.Application.Json)
                body = "{}"
            }
    c
    • 2
    • 4
  • d

    Dias

    10/25/2018, 4:45 PM
    and if there was a problem with certs I guess exception would have been thrown here
    requireNotNull(getKey(sslKeyAlias, sslPrivateKeyPassword.toCharArray()) == null) {
                        "The specified key $sslKeyAlias doesn't exist in the key store $sslKeyStorePath"
                    }
    in CommandLine.kt, but it hasn't been thrown
    c
    • 2
    • 7
  • d

    Dias

    10/26/2018, 9:20 AM
    I haven't touched lambda in a while, but does it really give you an http request to work with? Does it not just invoke function that you specify with some data passed in?
    b
    • 2
    • 1
  • n

    NGupta

    10/26/2018, 9:38 AM
    Hi guys, I am facing a strange issue with Ktor HttpClient(CIO). The client call looks like below: httpClient.get<HttpResponse> { method = HttpMethod.Get url("http://10.1.1.1") } It is expected to throw an error initially, I am catching that and recalling it after a delay. If I reinstantiate the client -> httpClient = HttpClient(CIO) in the catch block, it works fine. If I don't it stays as is forever, and never comes up with a response. Any help is appreciated
    e
    • 2
    • 1
  • n

    NGupta

    10/26/2018, 9:47 AM
    More to the point: This does not work: while (condition) { try { httpStatusCode = httpClient.get<HttpResponse> { method = HttpMethod.Get url("ActualURL") }.status.value } catch (exception: ConnectException) { delay(ppsConstant.delayTimeIntervalInSecondsForHealthCheck, TimeUnit.SECONDS) } } This works: while (condition) { try { httpStatusCode = httpClient.get<HttpResponse> { method = HttpMethod.Get url("ActualURL") }.status.value } catch (exception: ConnectException) { httpClient = HttpClient(CIO) delay(ppsConstant.delayTimeIntervalInSecondsForHealthCheck, TimeUnit.SECONDS) } }
    a
    c
    e
    • 4
    • 13
  • b

    bootstraponline

    10/26/2018, 2:11 PM
    https://github.com/ktorio/ktor/issues/678
    c
    n
    • 3
    • 5
  • k

    Kevin

    10/26/2018, 8:50 PM
    I recently tried out Ktor. One thing I found difficult was the examples all use wildcard imports. And so when I was making my own project I chose not to wildcard import which is super tricky since the DSL brings in extension methods from all over the place and if you miss one you get a non helpful error message. Is the expected usage that I'm going to wildcard import all of the ktor stuff?
    👍 1
    c
    • 2
    • 1
  • o

    orangy

    10/26/2018, 9:05 PM
    Multiconfiguration is covered by the HOCON itself, please check the docs: https://github.com/lightbend/config
    c
    • 2
    • 4
  • c

    coletz

    10/27/2018, 12:38 PM
    There's no built in logging capability on ktor client AFAIK. It was discussed some day ago. Seems like the best option is to use a mock client as a pass-through iirc, I'll try to find out the message
    o
    j
    • 3
    • 6
  • j

    jdemeulenaere

    10/27/2018, 5:17 PM
    Is receiving a ByteArray from HTTP call with Ktor JS implemented ? Sending works fine, but when the server responds with another byte array an error is thrown :
    No transformation found: class JsHttpResponse -> class null
    e
    • 2
    • 1
  • r

    Robert Menke

    10/28/2018, 12:35 AM
    @orangy For example in the node ecosystem Express has been a foundation that other frameworks have built on top of it. Examples: - https://docs.nestjs.com/ - https://feathersjs.com/ - https://sailsjs.com/ - https://adonisjs.com/ One of the awesome things about Ktor is that its design is very modular, and I’m wondering if people are building frameworks on top of Ktor that are more opinionated about architecture, design patterns, 3rd party libs, etc.
    o
    f
    • 3
    • 3
  • c

    claudiug

    10/28/2018, 6:33 PM
    good evening(berlin time). Does anyone try graal with native-image and ktor?
    l
    • 2
    • 2
  • s

    spierce7

    10/28/2018, 7:21 PM
    Why isn't there a
    io.ktor:ktor-client-json-js
    ? Is there a way to use kotlinx.serialization with ktor?
    e
    • 2
    • 4
  • n

    Narayan Iyer

    10/29/2018, 12:50 PM
    Any success implementing a
    JSON
    response with KTOR? Tried and got this:
    java.lang.IllegalArgumentException: Response pipeline couldn't transform 'class java.util.Collections$SingletonMap' to the OutgoingContent
    	at io.ktor.server.engine.BaseApplicationResponse$$special$$inlined$apply$lambda$1.invokeSuspend(BaseApplicationResponse.kt:38)
    	at io.ktor.server.engine.BaseApplicationResponse$$special$$inlined$apply$lambda$1.invoke(BaseApplicationResponse.kt)
    	at io.ktor.util.pipeline.PipelineContext.proceed(PipelineContext.kt:53)
    	at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:24)
    Checked out the documentation and saw this:
    install(ContentNegotiation)
    ... but documentation is sketchy ... any ideas?
    m
    s
    • 3
    • 7
  • m

    mp

    10/29/2018, 1:38 PM
    When writing a ktor feature, under what circumstances should the feature add a phase vs reusing an existing one?
    d
    c
    • 3
    • 50
  • d

    dimsuz

    10/29/2018, 5:12 PM
    Hi! I generated Ktor project using generator on ktor.io, then upgraded it to
    1.0.0-beta-3
    and kotlin
    1.3.0
    , but I cant run the server. I try this:
    $ ./gradlew run
    
    > Task :run FAILED
    Exception in thread "main" java.lang.IllegalArgumentException: Neither port nor sslPort specified. Use command line options -port/-sslPort or configure connectors in application.conf
            at io.ktor.server.engine.CommandLineKt$commandLineEnvironment$environment$1.invoke(CommandLine.kt:121)
            at io.ktor.server.engine.CommandLineKt$commandLineEnvironment$environment$1.invoke(CommandLine.kt)
            at io.ktor.server.engine.ApplicationEngineEnvironmentBuilder.build(ApplicationEngineEnvironment.kt:95)
            at io.ktor.server.engine.ApplicationEngineEnvironmentKt.applicationEngineEnvironment(ApplicationEngineEnvironment.kt:40)
            at io.ktor.server.engine.CommandLineKt.commandLineEnvironment(CommandLine.kt:50)
            at io.ktor.server.netty.EngineMain.main(EngineMain.kt:16)
    Although I have perfectly valid port in `resources/application.conf`:
    ktor {
        deployment {
            port =  8080
        }
        application {
            modules = [ com.example.ApplicationKt.module ]
        }
    }
    What am I doing wrong?
    📝 1
    ✅ 1
    d
    c
    • 3
    • 17
  • m

    mp

    10/29/2018, 5:39 PM
    In the
    SimplifiedSessionStorage
    example on https://ktor.io/servers/features/sessions/storages.html, what is the (not shown)
    getCoroutineContext()
    supposed to do in practice? Also that form of
    reader()
    is deprecated now --
    CoroutineScope.reader
    is probably what it should be, but on what scope?
    ✅ 1
    📝 1
    d
    • 2
    • 18
  • j

    Jonas Bark

    10/29/2018, 5:48 PM
    I'm trying the new ktor-client-json-js but getting the following error: "NoTransformationFound: No transformation found: class JsHttpResponse -> class StartPage at Coroutine$receive_jo9acv$.doResume (http://127.0.0.1:8080/lib/ktor-client-core-js.js:1240:21) I'm installing the JsonFeature like this:
    install(JsonFeature) {
    
                serializer = KotlinxSerializer().apply {
                    register(StartPage.serializer())
                }
            }
    The same code works just fine on iOS & Android Am I missing something here?
    s
    • 2
    • 5
  • j

    Jonathan

    10/30/2018, 8:57 AM
    Hi there. Is there a simple way to use grpc with ktor?
    g
    j
    • 3
    • 11
  • r

    RobinVdB

    10/30/2018, 12:24 PM
    Do you guys recommend ktor as a backend for a websocket server for a simple chat service (for college) I allready use ktor daily for REST apis
    h
    • 2
    • 2
  • f

    functionaldude

    10/30/2018, 2:25 PM
    Hi! I’m currently migrating one of my ktor (version
    0.9.5
    ) project to Kotlin
    1.3.0
    , but somehow this seems unsupported. Im using the new
    kotlinx-coroutines-core
    (version
    1.0.0
    ) but ktor still uses the older version, where many functions and classes are in the experimental package, therefore I always get a
    NoClassDefFoundError
    . Do you have any suggestions how to fix this? Or do I need to update ktor to
    1.0.0-beta3
    ?
    j
    m
    b
    • 4
    • 5
  • o

    orangy

    10/31/2018, 9:30 AM
    We plan to pay special attention to performance, but any bugs have higher priority, i.e. “Works, then Fast”. Otherwise we consider it Feature Complete for 1.0, and any additional features will come in the following releases.
    👍 5
    e
    g
    d
    • 4
    • 4
  • s

    Saša Šijak

    10/31/2018, 2:08 PM
    and there is 8080 port set in the application.conf
    ✅ 1
    s
    • 2
    • 7
  • s

    sannysoft

    10/31/2018, 2:32 PM
    Hello. Anybody faced the issue with location deprecation problem? https://github.com/ktorio/ktor/issues/688
    📝 1
    ✅ 1
    d
    l
    • 3
    • 8
  • n

    napperley

    11/01/2018, 12:48 AM
    Many exceptions are being thrown around reflection when using Zulu JDK 11. The server appears to run ok without any issues so far.
    app.log
    g
    d
    m
    • 4
    • 5
  • h

    Hamza

    11/01/2018, 5:49 AM
    is there a way to get the ip from the request? I tried printing the headers, and I don't think any of these are the IP from the request
    -.txt
    ✅ 1
    d
    g
    • 3
    • 7
  • s

    Saša Šijak

    11/01/2018, 6:04 AM
    How do you guys compare developer experience of ktor compared to spring boot? I am planning to start a new personal project soon and am evaluating ktor. As far as I saw from my small research, web layer is covered pretty well and for other parts you can pick and choose with a bit of plumbing (don`t have autoconfiguration like with spring boot for almost everything). I would like to try such approach again because when you have experience and know what you are doing you have better control of your app and you will not turn it into a spaghetti monster. Benefits that I see are that the code is easier to reason about and debug, there is less magic (no reflection and autoconfiguration) and the app is so much faster to start (this is a big for me currently, I`m tired of waiting 30s for a larger spring boot app to start on my macbook pro). Has anybody done apps in both spring boot and ktor and can provide some insight?
    s
    k
    • 3
    • 3
Powered by Linen
Title
s

Saša Šijak

11/01/2018, 6:04 AM
How do you guys compare developer experience of ktor compared to spring boot? I am planning to start a new personal project soon and am evaluating ktor. As far as I saw from my small research, web layer is covered pretty well and for other parts you can pick and choose with a bit of plumbing (don`t have autoconfiguration like with spring boot for almost everything). I would like to try such approach again because when you have experience and know what you are doing you have better control of your app and you will not turn it into a spaghetti monster. Benefits that I see are that the code is easier to reason about and debug, there is less magic (no reflection and autoconfiguration) and the app is so much faster to start (this is a big for me currently, I`m tired of waiting 30s for a larger spring boot app to start on my macbook pro). Has anybody done apps in both spring boot and ktor and can provide some insight?
s

sannysoft

11/01/2018, 8:27 AM
Spring Boot is definitely more stable but as for me quite overcomplciated. I like Ktor, but at the moment there still might be some minor bugs and what I don’t like much is Locations module and creating routes via Route functions (that should be added to route list manually). This part is way more beautiful in Spring with it’s controllers and annotations.
k

kenkyee

11/01/2018, 10:21 AM
What does the larger boot app use for features? Simple boot apps don't take that long. I'd make sure whatever framework you try has support for what you need.
s

Saša Šijak

11/01/2018, 11:11 AM
@sannysoft Spring Boot is actually adding a way to define the routes as in ktor. I like that way, you have more control, can test easier and is not constrained by annotations
View count: 4