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

    Sergio Casero

    10/18/2018, 11:12 AM
    Hi again! I've implemented the ktor core client and works really nice with Android and iOS, but the idea is to reuse the common client also with JS, is there any way? Because looks like
    io.ktor:ktor-client-json
    doesn't exists for JS, so I can't build the JS module, the dataSource is here -> https://github.com/sergiocasero/votlin-app/blob/feature/network_calls_common_client/common/src/main/kotlin/com/votlin/client/data/datasource/remote/CommonRemoteDataSource.kt
    j
    e
    • 3
    • 8
  • d

    Dias

    10/18/2018, 1:10 PM
    Hi, what is the reason for having this kind of structure for ktor samples, when you have resources folder at the top level along with src/? Compared to typical gradle project structure with resource inside of src/?
    d
    e
    • 3
    • 5
  • d

    Dias

    10/18/2018, 3:33 PM
    is there a way to block using standard non-ssl ports in ktor using embeddedServer?
    d
    • 2
    • 22
  • r

    russhwolf

    10/18/2018, 5:27 PM
    I'm still having trouble getting the ktor ios client to work with the
    kotlin-multiplatform
    gradle plugin. None of the ktor or coroutine dependencies resolve on the ios side when I build (
    ./gradlew clean build test
    ). I pushed a github repo of a minimal demo of what I'm trying to do, based on a fresh project with the IDEA "Kotlin (Mobile Android/iOS)" template. Here's the relevant commit: https://github.com/russhwolf/ktor-demo/commit/dfee772bfdc4fb97e6e84938780bd95b5589e0e6
    e
    • 2
    • 5
  • r

    russhwolf

    10/18/2018, 9:09 PM
    Ok new question. I gave up on tests and am trying to make calls in-app, copying the ios dispatcher from the client-mpp sample. However when I try to build my common code I get an error
    o
    o
    j
    • 4
    • 6
  • j

    Joris PZ

    10/19/2018, 1:10 PM
    I am working on a project involving multicast UDP. As far as I can tell, from the documentation and by looking through the ktor code (in particular
    UDPSocketBuilder
    ) , there seems to be no way to create a Multicast socket in ktor. Is that correct? And if so, does anyone know if it's on a roadmap?
    d
    • 2
    • 13
  • a

    Alex

    10/19/2018, 3:12 PM
    Is there a simple way to handle a post request validation in ktor?
    d
    e
    • 3
    • 9
  • e

    enleur

    10/19/2018, 6:07 PM
    is ktor supported on jdk 11? UPD found https://www.reddit.com/r/Kotlin/comments/90cqno/any_news_on_java_11_support/
    a
    • 2
    • 2
  • c

    coletz

    10/19/2018, 7:13 PM
    Is there any documentation for ktor-client-json? I'm not even sure what it is :s
    r
    • 2
    • 2
  • h

    Hamza

    10/20/2018, 4:03 AM
    Hi, I’m trying to use ktor multiplatform (jvm server and js client). I’m trying to get it to run with an application.conf but im running into a few issues. the application.conf is located at jvmMain/resources/application.conf, but i get an exception whenever I try to run it via `io.ktor.server.netty.DevelopmentEngine`:
    -.java
    d
    • 2
    • 8
  • m

    mp

    10/21/2018, 1:36 AM
    are you trying to do CORS or what?
    j
    • 2
    • 8
  • d

    dave08

    10/21/2018, 12:25 PM
    Is the response body read async, even with the OkHttp engine (I'm currently interested in downloads) @orangy? How stable is CIO?
    t
    j
    g
    • 4
    • 11
  • s

    samir

    10/21/2018, 5:24 PM
    Hey guys, I just migrated to Ktor
    1.0.0-beta-1
    and now all my usages of
    ApplicationConfig
    are generating warnings saying usage should be marked with
    KtorExperimentalAPI
    . What is the reason for this change ? Is there another way to use
    ApplicationConfig
    now ?
    • 1
    • 1
  • s

    Sergio Casero

    10/21/2018, 9:29 PM
    Hello guys! I don't where to put this issue... I'm trying to build my native module from a mpp project, but I'm getting this error:
    <--------Parallel execution is an incubating feature.
    
    > Task :ios:compileDebugIos_arm64KotlinNative FAILED
    Undefined symbols for architecture arm64:
      "_kfun:io.ktor.client.engine.ios.IosClient()io.ktor.client.engine.HttpClientEngineFactory<io.ktor.client.engine.HttpClientEngineConfig>", referenced from:
          _kfun:io.ktor.client.HttpClient(kotlin.Function1<io.ktor.client.HttpClientConfig<#STAR>,kotlin.Unit>)io.ktor.client.HttpClient in combined.o
      "_kfun:kotlinx.coroutines.CoroutineScope.<get-isActive>()ValueType", referenced from:
          _kmethods:io.ktor.util.pipeline.PipelineContext in combined.o
          _kmethods:io.ktor.client.call.HttpClientCall in combined.o
          _kmethods:io.ktor.client.HttpClient in combined.o
    ld: symbol(s) not found for architecture arm64
    error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors
    
    FAILURE: Build failed with an exception.
    Looks like it can't find the ktor client methods, no? The coroutines version is 1.0.0-RC1, and ktor client is 1.0.0-beta1. Android and JS works fine
    j
    e
    • 3
    • 10
  • e

    enleur

    10/22/2018, 11:49 AM
    is it possible to use DefaultDispatcher's pool as netty worker pool to avoid context switches? Not sure if it's a big deal anyway, but still?
    c
    • 2
    • 11
  • l

    legzo

    10/22/2018, 1:46 PM
    I stumbled upon Fuel this morning, didn't really like the "callbacky" syntax. But the project seems alive... I did not want to lose some time trying to make Ktor's client work outside of a server usecase but if you say it is usable, I think I'll go this way
    n
    • 2
    • 2
  • d

    Dias

    10/22/2018, 1:57 PM
    gentle boop 🙂 https://kotlinlang.slack.com/archives/C0A974TJ9/p1540210988000100
    • 1
    • 1
  • l

    legzo

    10/22/2018, 2:56 PM
    I managed to use Ktor's HttpClient (Apache) But when I try to call an HTTPs resource with a corporate certificate, it fails (logically). The question is : how can I provide HttpClient my custom trustStore ?
    e
    c
    d
    • 4
    • 8
  • c

    coletz

    10/22/2018, 3:54 PM
    How to set contentType to applicaton/json with ktor client? I tried both
    headers[HttpHeaders.ContentType] = ContentType.Application.Json.toString()
    and
    contentType(ContentType.Application.Json)
    but I get an exception:
    io.ktor.http.UnsafeHeaderException: Header Content-Type is controlled by the engine and cannot be set explicitly
    . How to set it with the engine? Considering I'm using ios so I'm not sure I can use ktor-client-json
    📝 1
    ✅ 1
    d
    k
    +3
    • 6
    • 14
  • b

    bootstraponline

    10/22/2018, 5:34 PM
    is ktor 1.0.0-beta-1 not compatible with kotlin 1.3.0-rc-190 and coroutines 1.0.0-RC1?
    -.java
    d
    • 2
    • 4
  • o

    oshai

    10/22/2018, 9:38 PM
    If you want async driver you can try what I am working on: https://github.com/jasync-sql/jasync-sql
    🎉 2
    • 1
    • 2
  • n

    NGupta

    10/23/2018, 9:52 AM
    Hi, I am new to this channel, have a very basic question if anyone could help. I plan to create a generic route for all my GET requests which would allow requests like http://localhost:8080/a http://localhost:8080/a/b http://localhost:8080/a/b/c/././././ As of now I have 3 levels of hierarchy and I am handling it like this: routing { get("/*") { //logic } get("/(STAR HERE)/*") { //logic } get("/(* HERE)/(STAR HERE) /*") { //logic } } I have something similar for posts, and the hierarchies are expected to grow. Thank you.
    e
    r
    • 3
    • 8
  • k

    kiffin

    10/23/2018, 9:58 AM
    See unresolved references in the screenshot
    c
    • 2
    • 1
  • k

    kiffin

    10/23/2018, 9:59 AM
    Tried with maven, gradle, ktor 0.94, 0.95 and 1.00-alpha but to no avail.
    c
    • 2
    • 1
  • k

    kiffin

    10/23/2018, 10:01 AM
    Do you mean running
    mvn build
    ?
    c
    d
    • 3
    • 25
  • c

    coletz

    10/23/2018, 10:52 AM
    is there any way to set request/read/write timeout with ktor client for ios?
    j
    c
    • 3
    • 11
  • r

    rocketraman

    10/23/2018, 5:43 PM
    It seems ktor 1-alpha has a binary incompatibility with coroutines 1.0.0-RC1?
    java.lang.NoSuchMethodError: kotlinx.coroutines.ExecutorsKt.asCoroutineDispatcher(Ljava/util/concurrent/ExecutorService;)Lkotlinx/coroutines/ExecutorCoroutineDispatcher
    ➕ 2
    n
    e
    +2
    • 5
    • 14
  • s

    Sergio Casero

    10/23/2018, 5:49 PM
    Hello! Is there any way to debug the ktor client calls?
    👍 1
    d
    c
    • 3
    • 10
  • s

    spierce7

    10/23/2018, 7:22 PM
    I'm seeing some problems when running the latest ktor on proguard. Anyone know the proper proguard for ktor?
    d
    • 2
    • 3
  • p

    patjackson52

    10/24/2018, 2:00 PM
    Any pointers on how to kotlin.serialize with HttpClient to deserialize json with lists as root? I’m using: HttpClient { install(JsonFeature) { serializer = KotlinxSerializer().apply { setMapper(MyClass::class, MyClass.serializer()) setMapper(AnotherClass::class, AnotherClass.serializer()) } } install(ExpectSuccess) } Appears I need to setMapper for List<MyClass>, however that is not possible with generics. I see I can get the serializer for it with MyClass.serialzer().list, but registering it to deseriralize/serialize on http requests is not straight forward. Anyone know of a good solution? https://stackoverflow.com/questions/52971069/ktor-serialize-deserialize-json-with-list-as-root-in-multiplatform
    m
    n
    j
    • 4
    • 16
Powered by Linen
Title
p

patjackson52

10/24/2018, 2:00 PM
Any pointers on how to kotlin.serialize with HttpClient to deserialize json with lists as root? I’m using: HttpClient { install(JsonFeature) { serializer = KotlinxSerializer().apply { setMapper(MyClass::class, MyClass.serializer()) setMapper(AnotherClass::class, AnotherClass.serializer()) } } install(ExpectSuccess) } Appears I need to setMapper for List<MyClass>, however that is not possible with generics. I see I can get the serializer for it with MyClass.serialzer().list, but registering it to deseriralize/serialize on http requests is not straight forward. Anyone know of a good solution? https://stackoverflow.com/questions/52971069/ktor-serialize-deserialize-json-with-list-as-root-in-multiplatform
m

Marcel Kesselring

10/24/2018, 2:04 PM
Last time I used kotlinx.serialization it wasn't possible to deserialize maps/lists on kotlin/js and I had to wrap every payload. Maybe that is still the case?
n

Nikky

10/24/2018, 2:06 PM
there should be a option to specify the serializer used at the callsite, at least in Fuel there is i have not used ktor-client for a while
p

patjackson52

10/24/2018, 2:06 PM
Interesting. I’m not targeting JS for this project though.
j

Jonas Bark

10/24/2018, 2:12 PM
right now it's not possible with KotlinxSerializer due to missing generic information. I had the same question - I'll search for the answer
n

Nikky

10/24/2018, 2:13 PM
i had hoped they made use of this in ktor: https://github.com/Kotlin/kotlinx.serialization/blob/master/runtime/jvm/src/main/kotlin/kotlinx/serialization/Resolving.kt#L59
i think you can make your own kotlinxserializer for ktor using this function, it will work for anything receiving at least since you have a typetoken there
j

Jonas Bark

10/24/2018, 2:14 PM
https://kotlinlang.slack.com/archives/C7A1U5PTM/p1539109136000100
n

Nikky

10/24/2018, 2:15 PM
last time i tried to do that for a outgoing jsonBody the pipeline did not have any typetoken
j

Jonas Bark

10/24/2018, 2:18 PM
@Nikky I think you mean TypeInfo - unfortunately the generic type is erased at runtime (see my link) so that won't help you in this case
p

patjackson52

10/24/2018, 2:18 PM
Right, I don’t think we have type of the generic. I may be able to get something working in my case, but a generic solution doesn’t seem possible currently
n

Nikky

10/24/2018, 2:20 PM
and there is a trick ktor uses to keep it in the pipeline https://github.com/ktorio/ktor/blob/master/ktor-client/ktor-client-core/ktor-client-core-jvm/src/io/ktor/client/call/TypeInfoJvm.kt
just not the pipline for sending data apparently
anyways this TypeInfo and its reified type could be passed to
serializerByTypeToken
on kotlinx-serialization
p

patjackson52

10/24/2018, 2:24 PM
thanks will take a look
I see what you are saying now NikkyAi. I am working with a multiplatform project though, so doesn’t look like serializerByTypeToken is an option.
n

Nikky

10/26/2018, 12:49 AM
well that seems annoying, in that case you can still use a serializer and turn it into a list serializer, you just way have to turn the result into a string and parse it then unless ktor-client has a method for passing in a custom serializer
View count: 4