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

    Anders Sveen

    11/17/2021, 10:44 AM
    Probably a basic question: But we want to launch a "background" task from KTor route. We can't get KTor to return the payload before everything completes. Even if we wrap the slow part (no need for the result) and do
    launch(<http://Dispatchers.IO|Dispatchers.IO>) { ... }
    It does return 200 fast, but wait with the payload till after launch completes. Any pointers on how to achieve this? 🙂
    a
    t
    j
    • 4
    • 15
  • m

    Mitchel Nijdam

    11/17/2021, 10:53 PM
    Hello from the Netherlands 👋 I have a question regarding Multiplatform. The client side of Ktor is already supporting mutliplatform usage and there is an effort in making the server have that as well. Does that mean that all plugins for either side are automatically supporting multiplatform too? If not, how can I find out which ones are or not?
    🇳🇱 5
    a
    • 2
    • 2
  • l

    lewik

    11/18/2021, 2:37 PM
    Can I use ktor client js in ServiceWorker?
    a
    • 2
    • 2
  • a

    Alex Styl

    11/18/2021, 5:00 PM
    I’ve noticed that sometimes auto reload (
    -t installDist
    ) would cause the page to load forever after a change is made. The only way to fix this is by stopping the server and running it again. It has started becoming much more frequent lately. Does anyone else get that?
    a
    • 2
    • 2
  • ł

    Łukasz Kłosiński

    11/18/2021, 8:54 PM
    I am trying to send the generated Template<FlowContent> as a text response (I do not want to send the full HtmlTemplate). So far I have got below:
    fun Route.test() {
        get("/test") {
            call.respondText(
                buildString {
                    appendHTML().div {
                        insert(TestTemplate(), TemplatePlaceholder())
                    }
                }
            )
        }
    }
    To make it work I have to wrap my TestTemplate in another div.
    <div>
      <div>this is the element I want to get, without the outer element</div>
    </div>
    Is there a way of doing it so I can send the actual template only, so I can get below:
    <div>this is the element I want to get, without the outer element</div>
    a
    • 2
    • 1
  • j

    jmfayard

    11/19/2021, 12:47 PM
    Hello friends, what are you using for error monitoring? Bugsnag, Raygun, Sentry ? What's the experience of using them with ktor like?
    r
    • 2
    • 1
  • j

    Javier

    11/19/2021, 12:52 PM
    @hhariri is it possible to change client artifact naming before last 2.0.0 is released? I think it is antintuitive that iOS client is used in more placed than iOS. Maybe renaming it to
    darwin
    for example. in general I find difficult to know how to setup a project which targets everything and uses a ktor client
    a
    e
    h
    • 4
    • 5
  • d

    Didier Villevalois

    11/19/2021, 2:45 PM
    Hi all, I published, to my maven local, the latest main branch in order to have 2.0.0-SNAPSHOT with Kotlin 1.6.0 (and a particular PR). In a project of mine where I declare
    ktor-io
    and
    ktor-network
    as implementation dependencies for my
    common
    source set, I now have an error "Could not resolve io.ktor:ktor-io:2.0.0-SNAPSHOT" that I don't understand. I found lots of similar errors in the Slack search but none hints me at what the problem is. This was working fine when I was using ktor 1.6.4-SNAPSHOT and Kotlin 1.5.31. (Gradle configuration and full error in thread.) Does anyone know what can be the problem ? Thanks in advance for you help.
    a
    • 2
    • 10
  • t

    Trond Øydna

    11/19/2021, 4:10 PM
    Hello 👋 After updating ktor to 1.6.5 my tests have started failing with the exception
    java.lang.NoSuchMethodError: java.nio.ByteBuffer.limit(I)Ljava/nio/ByteBuffer;
    using ktor-server-tests. I've not been able to find any other reports of this error here or on YouTrack. In the failing tests I'm making a mock request using
    io.ktor.server.testing.handleRequest
    . This has been working fine up until 1.6.5 Any ideas on what might cause this? I've added more details in thread. Edit: It seems it could be the JDK version, tests fail on 8 but not on 17. My JVM target is 1.8 and I'm dependent on kotlin-stdlib-jdk8
    a
    • 2
    • 4
  • j

    Jamal Khan

    11/20/2021, 12:30 AM
    i have a question regarding KTOR, is there any way to plugin in an engine that implements a non-HTTP protocol? KTOR looks really nice and i'd like it to be able to support a request/response framework that is proprietary.
    d
    h
    m
    • 4
    • 12
  • r

    Ruben Quadros

    11/21/2021, 1:21 PM
    Hi, I am new to KTOR and was trying to understand if we can send only status and empty body with ktor server. I was not able to find anything in docs regarding this. Thanks in advance!
    h
    • 2
    • 2
  • j

    John O'Reilly

    11/23/2021, 9:59 AM
    We're using
    staticRootFolder
    right now as part of Ktor server. Not sure this question makes sense....but wondering if there should be way to specify multiple folders?
    a
    • 2
    • 2
  • n

    Nikky

    11/24/2021, 11:12 AM
    i am trying to use ktor 2.0 eap and kotlin 1.6.0 to build a mingw64 binary from linux.. lld fails because it cannot find
    -lcurl
    .. which dependency do i need to install ? i assume some
    mingw-curl
    or is this something to be configured in the buildscript ? for now i am trying this in archlinux on WSL2, because i can easily try the binaries on the host
    a
    h
    • 3
    • 3
  • m

    Marko Kunic

    11/24/2021, 12:08 PM
    Hi all, I am following https://ktor.io/docs/testing.html#hocon guide on testing, the issue I am facing is when I do
    withApplication(testEnv)
    it doesn't load my module that is defined in
    application.conf
    but when I do
    withTestApplication(Application::main)
    it loads the module but the configuration is missing, not sure what am I doing wrong here?
    a
    • 2
    • 14
  • e

    Emil Kantis

    11/24/2021, 9:46 PM
    Adding annotations to the type parameter of
    HttpClient.get<T>()
    causes compilation to fail with
    Annotated types are not supported in typeOf
    http.get<BaseResponse<@Serializable(with = ItemSerializer::class) Item>>("/v1/items/$id")
    Failed to find anything related on google/youtrack/github . Filed a YT-issue here, but would be happy to close if someone can help me figure out what I’m doing wrong, or why this shouldn’t work, in general..
    a
    • 2
    • 5
  • r

    Raymond Boswel

    11/25/2021, 1:07 PM
    I'm working on a project that uses Ktor and Hibernate. Currently the project can only run using the gradle Shadow plugin. This however breaks hot reloading, since all classes are compiled into a jar file, preventing ktor from picking up changes. If I run without the Shadow plugin, then I get a '<Entity> is not mapped' message from Hibernate. Does anyone have a similar setup where they managed to get the auto reload functionality to work?
    d
    • 2
    • 2
  • r

    Rahul Rawat

    11/25/2021, 2:45 PM
    Is there a way to include ktor’s dependency to nativeMain sourceSet? I have tried looking for it but only have been able to find it for macOs which apparently uses the same client as iOS.
    • 1
    • 1
  • r

    Ruben Quadros

    11/25/2021, 3:53 PM
    Hi, at my ktor client I want to transform the server response to a custom one. I am intercepting
    HttpResponsePipeline.Transform
    for that. I want to know if we can parse error response from server as well at this point? Any help would be great! Code in thread.
    a
    • 2
    • 3
  • d

    Dennis Schröder

    11/26/2021, 7:36 AM
    Hey there, I am happy to present you an EventStoreDB Ktor-Server-Plugin. This Plugin is an seamless integration into the world of Ktor Server for the JVM. EventStoreDB is an open-source database technology that stores your critical data in streams of immutable events. It was built from the ground up for Event Sourcing. Checkout the official website for more information. Here you will find the plugin and information on how to use it. https://github.com/traxterz/ktor-plugin-event-store-db Hope you'll enjoy my work. Feel free to give some feedback and help to improve the plugin.
    🎉 4
    👍 5
    g
    k
    • 3
    • 3
  • a

    Alexandre Brown

    11/27/2021, 1:53 PM
    Hello, what are the differences (pros/cons) of a ktor backend on Kotlin Native vs GraalVM Native Image ? (Assume Ktor 2.0) Thanka
    ⭐ 1
    b
    n
    +5
    • 8
    • 63
  • n

    nordiauwu

    11/29/2021, 10:43 AM
    So I was trying out ktor 2.0 on K\N and it worked as expected with the old MM, but with the new one, I get the following error. It looks similar to KTOR-2947, but I'm not sure if it's the same one. Should I create an issue?
    error.txt
    e
    d
    • 3
    • 7
  • r

    Raymond Boswel

    11/29/2021, 10:54 AM
    Hi all, I'm having trouble with ktor's hot reload. My procedure is as follows: • run terminal> ./gradlew run • other terminal> ./gradlew -t build -x test -i • <hit endpoint> • run terminal> [12:38:06.094] DefaultDispatcher-worker-1 co.example.TestController Hot reload test • <update log to log.error("Hot reload test 3")> • run terminal> ktor.application Changes in application detected. • run terminal> Responding at http://0.0.0.0:11111 • <hit endpoint> • run terminal> [12:38:06.094] DefaultDispatcher-worker-1 co.example.TestController Hot reload test It appears to pick up the changes, but doesn't load in the updated classes. There doesn't seem to be a lot of configuration required, so I'm not sure what I could be missing?
    a
    • 2
    • 5
  • r

    Robert Jaros

    11/29/2021, 11:51 AM
    Why wasn't KTOR-3358 fix included in 1.6.6? Or maybe it was?
    a
    e
    • 3
    • 3
  • m

    Marko Kunic

    11/29/2021, 5:13 PM
    is there a way to consume request body 2 times? or should I consume it as a string (to get whole request and log it for debugging) and then manually deserialize it into an object?
    e
    a
    • 3
    • 2
  • a

    Alex Styl

    11/29/2021, 8:17 PM
    Has anyone run their ktor app on a digital ocean servlet? Not sure if I am doing something wrong, but running
    ./gradlew run
    makes gradle get stuck. Currently at 8minutes in
    a
    • 2
    • 3
  • e

    Emirhan Emmez

    11/30/2021, 8:23 AM
    hi, i have a problem about implementing https://github.com/papsign/Ktor-OpenAPI-Generator library for swagger. But after launching swagger-ui i'm facing a bug: Serializing collections of different element types is not yet supported. Selected serializers: [com.papsign.ktor.openapigen.model.schema.DataFormat, kotlin.Boolean, com.papsign.ktor.openapigen.model.schema.DataType]
    a
    j
    • 3
    • 5
  • n

    Nikky

    11/30/2021, 12:21 PM
    does anyone have a working ktor-client-native sample ? this one: https://github.com/ktorio/ktor-samples/tree/main/native-client is not finding some dependencies apparently, upgrading to a newer ABI version and upgrade to kotlin 1.6.0
    e
    d
    a
    • 4
    • 12
  • e

    Emirhan Emmez

    11/30/2021, 12:32 PM
    Caused by: org.koin.core.error.NoBeanDefFoundException: |- No definition found for class:'com.emirhan.controller.UserDataSourceImp'. Check your definitions!
    single<UserDataSource> { UserDataSourceImp() }
    single { UserController(get()) }
    Is anyone get this error about koin di?
    n
    • 2
    • 10
  • n

    Nikola Milovic

    11/30/2021, 5:53 PM
    How can I send files with Ktor client and FormData in KotlinJS? I receive files as
    FileList
    (which contains the actual Files) from React Input of type
    file
    . But I haven't found a way to append them to FormData. I tried using the
    org.w3c.xhr.FormData
    but I get the error
    IllegalStateException: Fail to serialize body. Content has type: class null, but OutgoingContent expected.
    But when I try to use the Ktors
    io.ktor.client.request.forms
    FormData, there is no override for
    append
    that accepts File type
    a
    • 2
    • 2
  • a

    Alex Styl

    11/30/2021, 6:06 PM
    How can I check in runtime if I am running in a development environment?
    a
    • 2
    • 1
Powered by Linen
Title
a

Alex Styl

11/30/2021, 6:06 PM
How can I check in runtime if I am running in a development environment?
a

Aleksei Tirman [JB]

11/30/2021, 6:58 PM
embeddedServer(CIO, port = 3333) {
    val app = this
    routing {
        get("/") {
            call.respondText { app.environment.developmentMode.toString() }
        }
    }
}.start(wait = true)
💯 1
View count: 22