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
server
  • р

    Ролан

    07/18/2021, 3:21 PM
    Hi everyone, could you please recommend a reactivate flow connector to Redis based on kotlin coroutines? Thanks
    d
    d
    3 replies · 3 participants
  • m

    Mustafa Ozhan

    07/20/2021, 10:26 AM
    Guys I have moved my backend to KMP, it is uses ktor with SQLDeleight When I run it on local with
    ./gradlew :backend:run
    everything works as expected I can reach it by
    <http://127.0.0.1:8080/endpoint>
    it reposes. I have created a fat jar and run in my server but I can not get response when i
    <http://IP_ADRESS:8080/endpoint>
    the main is below
    // Configs
    private const val PORT = 8080
    private const val HOST = "127.0.0.1"
    
    fun main() {
    ....
        embeddedServer(
            Netty,
            port = PORT,
            host = HOST
        ) {
    
            routing {
             ....
            }
        }.start(wait = true)
    }
    What can be the reason, I have allowed my port also
    c
    h
    5 replies · 3 participants
  • g

    gzhenjin

    07/22/2021, 9:15 AM
    Is this any engine for this in kotlin ?
    🤔 5
    p
    2 replies · 2 participants
  • a

    Alexander Suraphel

    07/27/2021, 2:00 PM
    what do you use for background work queueing. Something like celery in python?
    h
    p
    7 replies · 3 participants
  • v

    Venetia

    08/02/2021, 11:42 PM
    Hi All! Does anyone have experience running a kotlin service in Docker?
    c
    r
    3 replies · 3 participants
  • v

    Venetia

    08/03/2021, 6:58 AM
    Hi all - is anyone using gradle with kotlin with docker with buildkite? I'm trying to get my head around setting up a sensible pipeline.
    d
    2 replies · 2 participants
  • v

    Vitaliy Zarubin

    08/03/2021, 8:13 AM
    Which is better to choose Ktor http2 or WebSockets?
    c
    c
    4 replies · 3 participants
  • b

    Baidyanath

    08/04/2021, 6:14 PM
    Hi all, is anyone have worked on standardisation of rest API specifications, like - path conventions, request body conventions, variables, etc. I got one tool zally getting multiple issues while building the project. Any leads, suggestions will be highly appreciated as we have got to around 175+ micro-services for standardisation. #kotlin, #Groovy, #gradlew #jersey #rest
    h
    t
    4 replies · 3 participants
  • j

    jmfayard

    08/05/2021, 10:35 AM
    Hello friends! I want to learn ktor, and for me reading the docs is not enough. I want to learn it by re-implementing an existing API, bigger than hello world but still of a manageable size. In the past I reimplemented httpbin.org - and contributed that ktor sample - and I'm looking for something similar. Any idea?
    m
    m
    3 replies · 3 participants
  • j

    jean

    08/06/2021, 7:24 AM
    While looking for best user input sanitizing practices, I found that Ktor has a
    String.escapeIfNeeded
    method, is it enough to protect my database from injection and other possible attacks? I also found apache
    commons-text
    library that has
    StringEscapeUtils
    but it seems a bit less practical since there’s an escape method for java, one for ecmascript, etc…
    s
    v
    6 replies · 3 participants
  • e

    ESchouten

    08/06/2021, 4:24 PM
    Hi! I created a backend based on the Clean Architecture principles. Feedback would be very much appreciated! The application is separated into three modules: Domain, Usecases and Adapters • Domain module contains all entities, it's validation and repository interfaces • Usecases module performs actions on the domain entities and repositories and does authorization The domain and usecase modules do not have any external dependencies. • Adapter layer: each adapter is implemented as a standalone module, lowering dependence on specific frameworks and libraries and making them interchangable. The server module consumes all adapters (e.g. databases, (graphql) endpoints, authentication logic) GraphQL endpoints are auto-generated from the Usecases Used technologies: Ktor, JWT, Exposed, Flyway, KGraphQL/GraphQL generated endpoints. https://github.com/ESchouten/CleanArchitecture
    👏 3
    a
    5 replies · 2 participants
  • j

    João Pedro De Melo Garrido

    08/06/2021, 5:23 PM
    Hello everyone, been developing a restapi with ktor and ran into a problem with kors, on postman works fine but when i try doing it from website with fetch and javascript it runs into an error saying that "cannot convert from text/plain" even when im using fetch with content type application/json and when i have gson on my ktor server
    install(CORS) {
        method(HttpMethod.Get)
        method(<http://HttpMethod.Post|HttpMethod.Post>)
        method(HttpMethod.Put)
        method(HttpMethod.Delete)
        method(HttpMethod.Head)
        method(HttpMethod.Options)
        header(HttpHeaders.AccessControlAllowHeaders)
        header(HttpHeaders.AccessControlAllowOrigin)
        header(HttpHeaders.Authorization)
        allowCredentials = true
        allowSameOrigin = true
        anyHost()
    }
    this is my cors and when i add this line works (obvs cause it accepts text/plain) but dont understand whats happening
    allowNonSimpleContentTypes = true
    j
    1 reply · 2 participants
  • c

    Christian

    08/07/2021, 9:36 AM
    I have a question that has more to do with microservices than with Kotlin but I think here are the experts. I have my Profile/User - Service (A): there profiles are created and root information is stored e.g.: .
    User: {name: "potter", street: "hogwards-street", type: "cleaner"}
    I publish these to my message broker and consumed it in an another service (B). Now the service (B) only needs
    {name: String, type: String}
    . Should I still share the full model of
    User
    as interface between the services or are these other types of
    User
    models?
    :not-kotlin: 1
    c
    6 replies · 2 participants
  • s

    Solomon Tolu Samuel

    08/07/2021, 8:43 PM
    Hello guys. I have been trying to build a Docker image for my ktor server application and i keep on getting an error. This is the Docker and the .yml file:
    FROM openjdk:13 AS builder
    RUN java --version
    RUN mkdir /application
    WORKDIR /application
    COPY ./ ./
    RUN ./gradlew clean build
    RUN ls -al build/libs/
    ...
    version: "3"
    services:
      myapp:
        build: .
    And this is the error i keep getting:
    ERROR [6/7] RUN ./gradlew clean build                                                                                                                     1.9s
    ------
     > [6/7] RUN ./gradlew clean build:
    #10 1.339 /bin/sh: ./gradlew: No such file or directory
    ------
    executor failed running [/bin/sh -c ./gradlew clean build]: exit code: 127
    ERROR: Service 'myapp' failed to build : Build failed
    After trying lots of solutions, i decided to use another approach:
    FROM openjdk:8-jre-alpine
    ENV APPLICATION_USER ktor
    RUN adduser -D -g '' $APPLICATION_USER
    RUN mkdir /app
    RUN chown -R $APPLICATION_USER /app
    USER $APPLICATION_USER
    COPY ./build/libs/app.jar /app/app.jar
    WORKDIR /app
    CMD ["java","-server","-XX:+UnlockExperimentalVMOptions","-XX:+UseCGroupMemoryLimitForHeap","-XX:InitialRAMFraction=2","-XX:MinRAMFraction=2","-XX:MaxRAMFraction=2","-XX:+UseG1GC","-XX:MaxGCPauseMillis=100","-XX:+UseStringDeduplication","-jar","app.jar"]
    And i also got a similar error:
    ERROR [5/6] COPY ./build/libs/app.jar /app/app.jar                                                                                                        0.0s
    ------
     > [5/6] COPY ./build/libs/app.jar /app/app.jar:
    ------
    failed to compute cache key: "/build/libs/app.jar" not found: not found
    h
    d
    3 replies · 3 participants
  • j

    joseph_ivie

    08/09/2021, 3:20 PM
    Working on automatic migrations in Ktorm: https://github.com/kotlin-orm/ktorm-migration
    👏 2
    c
    e
    +2
    36 replies · 5 participants
  • y

    yuko fuyutsuki

    08/11/2021, 12:06 AM
    Hi. I'm trying to build a server that handles udp communication using raw sockets. However, when I open multiple sockets, the communication seems to be delayed by about 5000ms. Is this because ktor is not able to handle multiple sockets async or something?
    r
    d
    3 replies · 3 participants
  • p

    Pablo Schmid

    08/11/2021, 5:50 PM
    Hi, I have a question regarding Spring graphQL data/error management. I have a use case where I want to return several results, including the error ones, as a Union. something like this:
    extend type Mutation {
    userCreate(): UserCreatePayload
    }
    union UserCreatePayload = UserCreated | UserAlreadyExists
    I have a MutationsResolver that handles the
    userCreate
    mutation by calling a
    UserService
    that is transactional. When trying to create a user, if the user already exists, I'm throwing a
    UserAlreadyExist
    Exception that is handled in the mutation resolver with a try/catch block and then mapped to the UserAlreadyExists type in graphql. The problem is that as the UserService is transactional, whenever I throw the exception, the transaction is marked a rollbackOnly by spring (which is good) and then the graphql flow goes through the DefaultGraphQLErrorHandler that finally return an error to the end user. I would like to have the exactly same behavior except for the graphql error handler returning a GraphqlError. Instead I want to return the
    UserAlreadyExists
    type I defined in the graphql schema. Is there anyway to do so? (I do not want to use sealed classes instead of exceptions in the service as the code gets dirty) Thanks!
    d
    16 replies · 2 participants
  • s

    Sergey Dikunov

    08/11/2021, 7:57 PM
    Hi, I have a question about Ktor, maybe anyone solved this already: Is there a way to get/log actual amount of received/sent bytes for the HTTP request?
    h
    2 replies · 2 participants
  • y

    Yuval Dryer

    08/15/2021, 4:04 PM
    Hi All, I'm trying to run a Ktor server on android but cannot get the static webpage to display on the browser. I've added an assets folder and place the website as a subfolder in it, The request is recognized but the path I give in the response always seems to be wrong. Any ideas what I'm doing wrong?
    a
    3 replies · 2 participants
  • z

    Zhelenskiy

    08/18/2021, 11:45 PM
    Is there any overview of different server-side kotlin frameworks (e.g. Ktor, Spring Kotlin, http4k) with comparisons?
    ✅ 1
    a
    d
    +1
    5 replies · 4 participants
  • l

    Landry Norris

    08/19/2021, 7:21 PM
    I'm currently prototyping a Kotlin/JVM server app that will use Firestore as the backend data storage. I noticed that com.google.firebase:firebase-admin:8.0.1 seems to be lacking in documentation and Kotlin extensions for Firestore (Realtime DB seems to have a better experience, but doesn't fit the data structure I need as well). Does anyone know of a better Firestore library for Kotlin/JVM (specifically for a server application)?
    a
    4 replies · 2 participants
  • a

    Andre Stefanov

    08/21/2021, 11:49 PM
    hello everyone! i am building a ktor backend at the moment and use Locations for the routing. the documentation states
    If you provide additional class properties that are not part of the path of the @Location, those parameters will be obtained from the GET's query string or POST parameters
    While this seems to work fine for non-optional query parameters, i can't find any documentation on how to make the query parameters optional. out of intuition i tried to make location data class parameters nullable but this does not seem to lead to expected behavior. I wanted to have these routes:
    /user?page=1&count=10
    /user/{id}
    this was done with following code:
    @Location("/user")
    data class UserRoute(val page: Int?, val count: Int?) {
    
        @Location("/{id}")
        data class ById(val parent: UserRoute, val id: String)
    
    }
    but now performing a GET on
    /user
    results in a 404 if i don't provide the query parameters and works perfectly for
    /user?page=1&count=10
    is there any documentation i missed or maybe someone can give me a quick kick into the right direction? thank you in advance!
    😄 1
    3 replies · 1 participant
  • d

    Denis Ambatenne

    08/23/2021, 2:13 PM
    Hey folks! 👋 I'm a product manager for the :kotlin:Kotlin server-side. I'm looking for people to talk to about different aspects of their development experience from time to time. And today, I'm looking for folks who share code between their backend, web, and mobile apps. If you have such cases in your practice, please put ➕, and I will contact you. I appreciate your willingness and time, and after the interview, you will be able to choose your prize: an Amazon gift card or a one-year All-product pack subscription.🏆
    👋 2
    ➕ 10
    ł
    b
    +4
    6 replies · 7 participants
  • m

    Mickey Donaghy

    08/25/2021, 8:28 AM
    hi, if I cancel a coroutine
    Job
    is there a way to find out where it was stuck? I can pass a
    CancellationException
    in, but what I really want is a traceback for where it was when it got cancelled.
    c
    1 reply · 2 participants
  • s

    Samuel Osei Kwakye

    08/25/2021, 9:33 AM
    Hi, please is there a way to automatically generate swagger ui in ktor?
    h
    a
    +2
    12 replies · 5 participants
  • n

    Nolan

    08/26/2021, 3:37 PM
    I have a Kotlin/Spring Boot application in which I am doing a simple string comparison against a string literal within a list filter. Initially I used
    ===
    , and all of my unit tests passed. However, once deployed, the filter function did not work as expected. I wrote an simple JVM app to see if it was an issue with JVM specifically, but in that case
    "str" === "str"
    resolved to true, which is not the behavior I was seeing in my Spring Boot app. Any ideas why I'd be seeing this discrepancy in the Spring Boot app?
    d
    m
    +1
    8 replies · 4 participants
  • b

    Baidyanath

    08/29/2021, 2:56 PM
    Hello everyone, is it possible to get all the keys of nested Json using Kotlin without using actual class, similar to JavaScript?
    a
    a
    +1
    14 replies · 4 participants
  • j

    Jakub Neukirch

    09/07/2021, 5:32 PM
    How can I dynamically set CORS in ktor.io? Unfortunatelly
    call.request.origin.host
    returns
    localhost
    and after some reconfiguration of nginx it returns
    <http://backend.domain.com|backend.domain.com>
    instead of
    <http://frontend.domain.com|frontend.domain.com>
    . Setting up CORS for all endpoints with
    host("<http://frontend.domain.com|frontend.domain.com>")
    works properly, allows only frontend domain, and blocks all other
    h
    19 replies · 2 participants
  • m

    Minsoo Cheong

    09/09/2021, 1:34 AM
    Hi guys, I've read that kafka consumers are not thread-safe. does this mean that I can't(or shouldn't) run consumers in asynchronous servers? sry if this is a dumb question. yep it was 😅 i guess multithreading is not allowed while async is different
    c
    1 reply · 2 participants
  • s

    Slackbot

    09/09/2021, 11:34 AM
    This message was deleted.
    a
    1 reply · 2 participants
Powered by Linen
Title
s

Slackbot

09/09/2021, 11:34 AM
This message was deleted.
a

Ahsan Raza

09/09/2021, 12:23 PM
@Vampire Okay! Got it...any answer about my query!
View count: 9