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

    spawlak

    09/25/2019, 2:07 PM
    Hi folks. I'm playing around with ktor. I'm trying to write some integration tests for my REST resource that accepts JSON content. Right now I do it like in the snippet and everything is working. As you can see I have to "manually" serialize data object to JSON (
    mapper.writeValue...
    ) and set it as a body for the request. Is there any nicer way to do this in integration tests and just provide and object that would be then later on automatically serialized by test framework??
    Example test
    ✅ 1
    c
    m
    12 replies · 3 participants
  • t

    Tony Blundell

    09/25/2019, 3:53 PM
    Hi, I’m using Ktor Client and MockEngine as per https://ktor.io/clients/http-client/testing.html. I’d like to check the request body that is being generated. How can I get the full body? I’ve tried request.body.toString() but that returns a concatenated version.
    ✅ 1
    c
    3 replies · 2 participants
  • w

    wilyarti

    09/26/2019, 6:36 AM
    I am writing a CMS in Kotlin that uses DSLs to produce pages (Kotlinx). I need to add authentication for the administrative side of things and to create custom content for each user. Any ideas of a good fit for Ktor?
    t
    d
    +1
    17 replies · 4 participants
  • m

    Marc Knaup

    09/26/2019, 1:53 PM
    Uhm, why has the list of headers allowed by default for CORS requests been reduced in a patch update of Ktor? That caused quite some unexpected CORS issues which took time to solve…
    c
    9 replies · 2 participants
  • a

    ankit.sharma

    09/27/2019, 12:34 AM
    Hey guys, sorry if this has been asked before. I'm learning ktor and trying to set up signup/login functionality. I have the setup working and want to send a confirmation email from the server to the user's provided email, which the user can click and it opens a
    Your email is confirmed
    webpage, and sends a request to the server about the confirmation. How do I do that? Can someone link me to some docs or blogs. Thanks!
    t
    2 replies · 2 participants
  • m

    mmaillot

    09/27/2019, 4:10 PM
    Hello, there is way to protect a route with an API-KEY header?
    d
    k
    +1
    8 replies · 4 participants
  • h

    hallvard

    09/30/2019, 7:20 AM
    I find the routing in ktor to be less clear than I like. Coming from the play framework, I may be spoiled by the very straightforward routes file over there. Are there any tricks I should know about that could ease my life here? (A 200-endpoint routes file actually is no problem for a human eye to parse in the Play framework, but reading the same amount of endpoints from a routing {} DSL in ktor is less so ...)
    a
    p
    +2
    11 replies · 5 participants
  • m

    Miguel Fermin

    10/01/2019, 8:53 AM
    message has been deleted
    c
    3 replies · 2 participants
  • b

    bitkid

    10/01/2019, 11:15 AM
    is there somewhere an example for parallel file upload with ktor client?
    d
    j
    36 replies · 3 participants
  • m

    Marcin Wiśniewski

    10/03/2019, 1:27 PM
    Is there any working example of REST API application with ktor and swagger?
    e
    e
    +1
    9 replies · 4 participants
  • s

    Steve Young

    10/03/2019, 1:53 PM
    is it possible to ignore SSL certificate error when using the Ktor IOS httpClient?
    e
    2 replies · 2 participants
  • l

    legzo

    10/03/2019, 3:22 PM
    Hi guys, I am looking for any info regarding Open Tracing implementation in Ktor. I searched and found a few personal initiatives but nothing really reusable. Is there a plan to implement such a thing (getting current trace context in servers and propagating it in clients) ? How would you implement it if it does not exist ? Thanks
    l
    1 reply · 2 participants
  • m

    martin.petrulak

    10/04/2019, 9:25 AM
    Hello, iam starting with K-Tor , i have build a few endpoints that i can access from browser on my machine, from emulator browser via
    <http://10.0.2.2:8080/>....
    , but when iam trying to get the data from android app via
    client.call("<http://10.0.2.2:8080/....>")
    i get
    java.net.ConnectException: Failed to connect to localhost/127.0.0.1:80
    any ideas what might be wrong?
    👀 1
    e
    s
    5 replies · 3 participants
  • s

    Szymon Lipiński

    10/04/2019, 3:41 PM
    it seems like the official documentation is bad
    e
    6 replies · 2 participants
  • c

    coder82

    10/06/2019, 3:07 PM
    The kotlinx serializer was not able to parse this, due to the double precision I suspect: https://api.coincap.io/v2/assets?search=eth @e5l
    d
    1 reply · 2 participants
  • c

    coder82

    10/06/2019, 3:08 PM
    Untitled.txt
    d
    1 reply · 2 participants
  • s

    Szymon Lipiński

    10/06/2019, 7:42 PM
    What's the proper way to write the hocon configuration file, configure production server based on an external file with a modified data, and also use a local file to run in intellij with autoreloading? Whatever I do, it doesn't work, any working example would be great.
    1 reply · 1 participant
  • s

    Szymon Lipiński

    10/06/2019, 8:46 PM
    I really stuck with this: I need to integrate flyway with the ktor and a custom application.conf file. I have my database connection configured in the application.conf, so I need to have it also use in the flyway when applying migrations... and the place where the conf file is read changes, on my machine is resources/application.conf, on production, who knows, it will be passed as an argument. It looks like a normal configuration, however, it's not really easy to do it.
    e
    m
    +1
    22 replies · 4 participants
  • r

    ribesg

    10/07/2019, 9:43 AM
    Can you use Locations in a common module so that they can also be used by a Ktor client directly, or is it planned? It would be cool to be able to do things like
    httpClient.get<SearchResponse>(SearchLocation("myQuery"))
    ➕ 1
    g
    1 reply · 2 participants
  • s

    Szymon Lipiński

    10/07/2019, 12:12 PM
    @Magno Junior Hey, here is my proof of concept how wiring of the Flyway with the ktor config file could look like. I used the libraries I'm going to use in my real project. https://github.com/szymonlipinski/ktor-flyway
    m
    13 replies · 2 participants
  • j

    janvladimirmostert

    10/07/2019, 12:19 PM
    I've switched out Netty for CIO as the Ktor server to see if the performance would be better, but it seems much worse. Is CIO supposed to outperform Netty now or at some point or can it be tweaked to do that? On Netty, my throughput is about 38,000 requests per minute with 2.5 seconds per request. On CIO it's only about 21,000 and each request takes almost 5 seconds
    j
    a
    12 replies · 3 participants
  • d

    Dario Pellegrini

    10/07/2019, 12:42 PM
    Hello everybody! I have a question as a newby. I’d like to implement on ktor 2 endpoint: one authenticated and one not, but with the same endpoint Something like authenticate(“jwt”) { get(“hello”) { call.respond(“Authenticated”) } } get(“hello”) { call.respond(“Public”) } The above is of course not working. Is there a way to achieve this?
    l
    2 replies · 2 participants
  • j

    jlleitschuh

    10/07/2019, 4:39 PM
    @cy @orangy @e5l You guys still want me to use the JetBrains Security email to report a vulnerability or do you guys want to give the new GitHub Security Advisories process a spin? https://github.com/ktorio/ktor/security/advisories
    y
    6 replies · 2 participants
  • b

    bitkid

    10/08/2019, 10:32 AM
    i am trying to read a csv file from a multipart request and somehow it behaves weird. when i do
    for (line in part.streamProvider().reader().readLines())
    it fails with "Underlying input stream returned zero bytes" but when i do
    for (line in ByteArrayInputStream(part.streamProvider().readAllBytes()).reader().readLines())
    it works as expected. the weird part is when i run "unix2dos file" before uploading it, it works also with the first bit of code. do i need some content type headers or something like this? reading the file locally also works with the first part, so something along the lines
    for(line in File("bla").reader().readLines())
    5 replies · 1 participant
  • j

    Joris

    10/08/2019, 1:55 PM
    When looking to the generated trace in the first case the
    /api
    isn't prepend to the other routes as I fought it would, instead ktor try to match /api or /foo or /baz. Is there a way to mutualize a part of a route without adding it in every Routing ? It's quite redundant to put the
    /api
    in every Routing file that I might create. Also in my web.xml I tried to put
    /api
    in the url-pattern, but ktor doesn't seems to base its matching on it and try to work from
    /
    instead.
    d
    r
    3 replies · 3 participants
  • a

    Adriano Celentano

    10/10/2019, 9:16 AM
    I want to run ktor Server in an Android App. I heard it is possible. But the Problem is i have to use tls. Can i also Provider a certificate ?
    m
    10 replies · 2 participants
  • b

    bitkid

    10/10/2019, 3:12 PM
    what's the fastest, most efficient way to write big string responses with ktor server netty engine (>200MB)?
    b
    s
    4 replies · 3 participants
  • j

    Jason

    10/10/2019, 6:16 PM
    Hey all 👋 - new to ktor and kotlin. Struggling to find a way to run a REPL that has my ktor (really
    build.gradle.kts
    I suppose) environment loaded. Also open to someone giving me a slap and explaining why this is not a necessary/useful part of your workflow (I'm coming from Rails/Phoenix worlds where this is commonplace).
    m
    3 replies · 2 participants
  • v

    Vinicius Araujo

    10/10/2019, 8:43 PM
    Hey everyone! Is there a way to access the Principal instance of an authenticated call, outside the route definition?
    w
    2 replies · 2 participants
  • a

    Adriano Celentano

    10/11/2019, 8:39 AM
    Im trying to make ktor server running inside an Android App. The Problem is i also need to provide ssl. I generated a self signed certificate with .jks I could not generate it from android and i cant load it from android assets. It seems like Android is not supporting jks. Is there another self signed certificate Type supported by ktor ?
    j
    v
    34 replies · 3 participants
Powered by Linen
Title
a

Adriano Celentano

10/11/2019, 8:39 AM
Im trying to make ktor server running inside an Android App. The Problem is i also need to provide ssl. I generated a self signed certificate with .jks I could not generate it from android and i cant load it from android assets. It seems like Android is not supporting jks. Is there another self signed certificate Type supported by ktor ?
j

Jorge R

10/11/2019, 8:43 AM
is it mandatory communication through android? dont you have a different way to work to place a different architecture?
in a regular arch Im setting an Nginx to handle SSL certs
a

Adriano Celentano

10/11/2019, 8:45 AM
Our requiremt is to serve a rest enpoint someone can call to Trigger calls to an Android App and get a response
So another solution we thought of to run the Server not on Android but as a Middleware which communicates with the App via websockets
@Jorge R u think nginx would Help in my case?
j

Jorge R

10/11/2019, 8:47 AM
trigger calls to android app
that looks like going completely the other way around how the regular arch works for Android as a frontend
what I have: (Android) Users -> Nginx -> Ktor backend
Android has many peculiarities and restrictions coming from the platform itself
so this could be a deal breaker for you, as it is not intended to be use mainly as a server
a

Adriano Celentano

10/11/2019, 8:50 AM
Ah no my case Android should be the Server ^^
It can all run in the same wifi
j

Jorge R

10/11/2019, 8:51 AM
what would the server do?
because if you want Android as a server, it may be just server UI
and delegate everything to Ktor
you really need an android device to host everything?
would it be possible for you to setup another device with Ktor?
a

Adriano Celentano

10/11/2019, 8:52 AM
I need to have a rest enpoint which calls my Android app
j

Jorge R

10/11/2019, 8:53 AM
so I guess you need android to do something for you
a

Adriano Celentano

10/11/2019, 8:53 AM
Yes that was my first approach to make a ktor Server and communicate with Android via websockets
But i try to find out If i could do the Server directly on android
Without a Middleware
But self signed tls seems to be the Tricky Part to Set up
j

Jorge R

10/11/2019, 8:55 AM
the main problem here is the environment where you will be running your server (Android)
a

Adriano Celentano

10/11/2019, 8:55 AM
Exactly
j

Jorge R

10/11/2019, 8:55 AM
so, i would say fight against the monster (I would not recommend) or try to find a different approach
I’ve been doing projects in Android where I wanted Android as a dedicated device
a

Adriano Celentano

10/11/2019, 8:56 AM
Yeah lets see, If i find sth i can report it here
j

Jorge R

10/11/2019, 8:56 AM
and I can tell you it is not designed for certain tasks
can the task that android have to do being done in other platform (linux, etc)?
v

Viktor Penelski

10/11/2019, 10:14 AM
@Adriano Celentano sorry if I misunderstood, but based on the requirements you mentioned - can't you take advantage of push notifications? That would allow you to send messages from the "outside" to an android device without having to run a dedicated server in your app
a

Adriano Celentano

10/11/2019, 10:50 AM
Yeah was my first solution as well. But i didnt know i also have to communicate back + the api is fixed so i would also need map the incoming request to a push request on firebase or similar
j

Jorge R

10/11/2019, 11:04 AM
also keep in mind that push notif are not 100% guaranteed to arrive
a

Adriano Celentano

10/11/2019, 11:11 AM
We made it work by using a bks certificate :-)
👍 2
View count: 7