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

    Deactivated User

    04/18/2018, 10:47 AM
    ^ @otakusenpai
    o
    • 2
    • 25
  • o

    otakusenpai

    04/18/2018, 12:14 PM
    how do i sleep an app which is using coroutines and ktor for say like 6 secs?
    d
    c
    • 3
    • 11
  • d

    Deactivated User

    04/18/2018, 2:02 PM
    @otakusenpai ^
    o
    • 2
    • 3
  • d

    dave08

    04/19/2018, 12:56 PM
    Or maybe I'm missing something in the docs @Deactivated User? I looked under Structure (advanced..) and Deploy... but no mention of it...
  • d

    dave08

    04/19/2018, 1:19 PM
    I guess I'll need the full repo around as a reference in the future...
    d
    • 2
    • 9
  • d

    dave08

    04/19/2018, 1:23 PM
    Funny that I have to start a whole application for this though, on one hand it's more flexible, but it means re-installing all the same features for both, etc... it might have been nice to have
    routing { port(8080) { ... } ; port(9090) { ...} }
    ?
    d
    c
    • 3
    • 4
  • o

    orangy

    04/19/2018, 2:40 PM
    I believe you shouldn’t need to start two servers, just provide two connectors. Am I right @cy?
    c
    d
    d
    • 4
    • 18
  • r

    rocketraman

    04/20/2018, 1:45 AM
    This article on Medium pans ktor, and I wouldn't say it was done fairly: https://medium.freecodecamp.org/going-beyond-android-kotlin-on-the-backend-2a75eef2582b
    o
    • 2
    • 1
  • o

    otakusenpai

    04/20/2018, 6:06 AM
    can someone help me with this one https://hastebin.com/uzetogurup.php ?
    g
    • 2
    • 9
  • o

    orangy

    04/22/2018, 8:56 PM
    Specifically https://github.com/lightbend/config#uses-of-substitutions
    d
    • 2
    • 11
  • k

    kevin.cianfarini

    04/22/2018, 11:10 PM
    And building on that, how does a coroutine know when to suspend and resume?
    a
    • 2
    • 1
  • w

    wiyarmir

    04/23/2018, 8:36 AM
    hey, I've seen people quote this link to say ktor is not performant, but from the data there it seems that they did not even run the tests? https://www.techempower.com/benchmarks/#section=data-r14&hw=ph&test=plaintext
    s
    • 2
    • 5
  • w

    wiyarmir

    04/23/2018, 8:37 AM
    any other benchmarks with comparable results?
    c
    r
    • 3
    • 5
  • d

    deviant

    04/23/2018, 9:09 AM
    is there updated docs or example for new auth api?
    c
    d
    • 3
    • 3
  • d

    dave08

    04/23/2018, 12:12 PM
    Also, if doing blocking processing in an
    ApplicationCall
    context, what's the better practice, to use suspending functions,
    withContext(CommonPool)
    , or
    async { }
    (since some processing can be done in parallel..)?
    c
    d
    • 3
    • 49
  • n

    Nail Gilaziev

    04/23/2018, 5:08 PM
    outdated documentation part https://ktor.io/clients/http-client.html#cio
    val client = HttpClient(CIO.config { 
        maxConnectionsCount = 1000 // Maximum number of socket connections.
        endpointConfig = EndpointConfig().apply {
            maxConnectionsPerRoute = 100 // Maximum number of requests for a specific endpoint route.
            pipelineMaxSize = 20 // Max number of opened endpoints.
            keepAliveTime = 5000 // Max number of milliseconds to keep each connection alive.
            connectTimeout = 5000 // Number of milliseconds to wait trying to connect to the server.
            connectRetryAttempts = 5 // Maximum number of attempts for retrying a connection.
        }
    })
    endpointConfig - Unable to resolve if I understand correctly this line must be replaced to:
    endpoint.apply {
    📝 1
    ✅ 1
    c
    d
    • 3
    • 2
  • n

    Nail Gilaziev

    04/24/2018, 9:21 AM
    can I configure websocket client ping periods and timeouts? websocket client described here https://ktor.io/clients/websockets.html
    To use this feature, you need to include io.ktor:ktor-client-websocket artifact.
    📝 1
    ✅ 1
    d
    • 2
    • 3
  • v

    v

    04/24/2018, 10:19 AM
    HttpClient(CIO).get<String>(
    I've tried this with both CIO and Apache, I just get an error
    No transformation found: class io.ktor.client.engine.apache.ApacheHttpResponse -> class kotlin.String
    According to https://ktor.io/clients/http-client.html this should work?
    📋 1
    👀 1
    d
    • 2
    • 2
  • o

    otakusenpai

    04/24/2018, 1:14 PM
    how can i use ssl with raw sockets?
    📝 1
    ✅ 1
    📋 1
    d
    e
    • 3
    • 40
  • v

    v

    04/24/2018, 1:16 PM
    Is there a utility method for creating
    ContentType.Application.FormUrlEncoded
    strings? I'm currently doing it manually.
    📝 1
    d
    z
    • 3
    • 3
  • u

    ubu

    04/24/2018, 8:22 PM
    Hi there. Is it possible to combine Ktor with Firebase hosting?
    g
    • 2
    • 2
  • u

    uli

    04/24/2018, 9:39 PM
    Can ktor client limit the number of concurrent connections? Something like this code for HttoAsyncCliebt:
    CloseableHttpAsyncClient httpclient = HttpAsyncClients.custom()
        .setMaxConnTotal(100)
        .setMaxConnPerRoute(10)
        .build();
    ✅ 1
    📝 1
    e
    d
    • 3
    • 5
  • o

    otakusenpai

    04/25/2018, 6:40 AM
    https://hastebin.com/udeyivodop.scala @e5l
    👀 1
    e
    d
    • 3
    • 7
  • n

    Nail Gilaziev

    04/25/2018, 9:09 AM
    Websocket CIO client and netty websocket server - both hides under the hood PING/PONG packets, right? I see this ping pong packets via wireshark but this code never was invoked:
    incoming.mapNotNull { it as? Frame.Ping }.consumeEach { frame ->                
                    println("ping arrived")
    }
    I want to use ping/pong packets to determine user online status. it is correct way or no?
    📝 1
    e
    • 2
    • 3
  • n

    Nail Gilaziev

    04/25/2018, 9:25 AM
    And second problem with WebSockets implementation is that pingPeriod and timeout are not interrelated. Maybe I'm wrong... I must be wrong, please)
    pingPeriod = Duration.ofSeconds(30) // Disabled (null) by default
    timeout = Duration.ofSeconds(15)
    When connection between client & server are unexpectedly broken(TCP not closed properly) I expect that an exception will thrown after maximum of 45 seconds.(ping period+*pong* response waiting timeout). But it not happens. What am I do wrong? Should I independently implement this behavior through raw sockets?
    👀 1
    e
    • 2
    • 7
  • r

    Raquel V

    04/25/2018, 10:03 AM
    Hi guys, I am trying to send a compressed response back to the browser using call.respondWrite like
    call.respondWrite(contentType = ContentType.Application.GZip) {
                        val output = WriterOutputStream(this)
                        val writer = BufferedWriter(OutputStreamWriter(GZIPOutputStream(output), "UTF-8"))
    
    ...
    but this is not compressing the response, do you see anything weird there? or can you point me out to other way of doing it with ktor?
    d
    • 2
    • 1
  • r

    rocketraman

    04/25/2018, 1:05 PM
    @dave08 The java opts
    -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:InitialRAMFraction=2 -XX:MinRAMFraction=2 -XX:MaxRAMFraction=2
    can be used on a recent JDK8 as well. As I understand it, JDK10 just makes container awareness automatic.
    ✅ 1
    📝 1
    d
    d
    • 3
    • 3
  • r

    rocketraman

    04/25/2018, 1:17 PM
    Here is the OpenJDK issue related to CPU limit support: https://bugs.openjdk.java.net/browse/JDK-8140793
    d
    • 2
    • 2
  • v

    v

    04/26/2018, 9:48 AM
    The embedded netty server is very convenient for development (or for someone else to clone the project and quickly run it), but shouldn't be a dependency for production builds. What's the best way to do this? I've been thinking of defining a develop/production property in a gradle settings file, and conditionally including the dependency.
    d
    • 2
    • 8
  • n

    Nail Gilaziev

    04/26/2018, 3:04 PM
    Yes, I have the application plugin. Please tell more detailed, what I need to do in this case?
    d
    • 2
    • 9
Powered by Linen
Title
n

Nail Gilaziev

04/26/2018, 3:04 PM
Yes, I have the application plugin. Please tell more detailed, what I need to do in this case?
d

Deactivated User

04/26/2018, 3:09 PM
https://github.com/ktorio/ktor-samples/blob/master/deployment/docker/build.gradle
This sample generates a fatjar
ls -la deployment/docker/build/libs
total 22568
drwxr-xr-x   4 soywiz  staff       128 Apr 25 18:32 .
drwxr-xr-x  10 soywiz  staff       320 Apr 25 18:32 ..
-rw-r--r--   1 soywiz  staff     15995 Apr 25 18:35 docker.jar
-rw-r--r--   1 soywiz  staff  10979065 Apr 25 18:35 my-application.jar
In build/libs you would have two jar files
the one that is bigger contains all the required dependencies In this case it would be
java -jar deployment/docker/builds/libs/my-application.jar
n

Nail Gilaziev

04/27/2018, 1:22 PM
how can I produce fat.jar without gradle docker build command? shadowJar task produce jar (~11MB) that I can't run for now.
Exception in thread "main" com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'ktor'
I will try to create a new project and from scratch configure all the things - I think I broke something during my experiments
the question is removed. Configured everything from scratch - and it worked.
16:37:27: Executing task 'shadowJar'...

:compileKotlin
:compileJava NO-SOURCE
:processResources
:classes
:shadowJar

BUILD SUCCESSFUL in 11s
3 actionable tasks: 3 executed
16:37:39: Task execution finished 'shadowJar'.
👍 1
View count: 7