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

    Hamza GATTAL

    11/27/2020, 6:48 PM
    Hi everyone Anyone face this error before Exception in thread "eventLoopGroupProxy-3-1 @response-pipeline#3" kotlinx.coroutines.CoroutinesInternalError: Fatal exception in coroutines machinery for DispatchedContinuation[UnsafeBlockingTrampoline@76907f9f, Continuation at io.ktor.utils.io.jvm.javaio.OutputAdapter$loop$1.loop(Blocking.kt:311)@aa7a293]. Please read KDoc to 'handleFatalException' method and report this incident to maintainers
    c
    • 2
    • 3
  • n

    Nikky

    11/27/2020, 8:38 PM
    i have a global
    val client = HttpClient(OkHttp)
    and apparently it opens a coroutine / thread that is not closed when the program is done.. so it hangs i am not entirely sure what change on my side triggered this or if i am using it incorrectly if i do
    exitProcess(0)
    i can kill it but i'd prefer to avoid that more in :thread-please:
    b
    r
    • 3
    • 4
  • e

    elcamomile

    11/28/2020, 4:07 PM
    Hi everybody! 👋 My name is Elvira, I’m doing research on how developers are using Ktor for server-side development, and particularly its plugin for IDEA, to figure out its potential improvements. For that I’d like to speak to you about your experience with it. Would anyone be up for a short interview sometime this weekend or early next week? It won’t take longer than 30 min. If so, please, drop me a private message or leave a comment here in the thread. Thank you very much, I’d really appreciate it!
    d
    • 2
    • 1
  • c

    Cicero

    11/28/2020, 11:30 PM
    I actually didn’t solved. Suddenly it began doing this thing of chopping my request again. I got to where it is happening but still don’t get why So, in the Ktor.JVM, when this data goes in: “Reminder(actionType=boolean, from=slorg@gmail.com, hours=[200], startDate=2020-10-29T01:31:16.993Z, title=Hkkljf, to=jorebs@gmail.com, frequency=1, frequencyType=no_repeatable)” And when it goes trough package
    io.ktor.client.features.json.serializer
    internal fun writeContent(data: Any): String =
        json.encodeToString(buildSerializer(data, json.serializersModule), data)
    This is in like 29 this comes out: {“from”:“slorg@gmail.com”,“hours”:[200],“startDate”:“2020-10-29T01:31:16.993Z”,“title”:“Hkkljf”,“to”:“jorebs@gmail.com”}
    m
    • 2
    • 6
  • b

    ByFloRedstone

    11/29/2020, 12:09 PM
    How can I imagine the Ktor websockets? Are they so that the browser permanently shows "refresh" or are they like a JavaScript file so that the user doesn't really notice them?
    m
    • 2
    • 2
  • r

    rudolf.hladik

    11/29/2020, 9:21 PM
    So Ktor Http client with default engines for Android and iOS doesn’t support mt coroutines and Ktor http client with CIO engine supports mt coroutines but doesn’t support https? Is it this way or am I doing something wrong?
    t
    j
    • 3
    • 6
  • b

    ByFloRedstone

    11/30/2020, 5:45 PM
    Hey how can a store a websocket session to send a message to the websocket later?
    b
    • 2
    • 26
  • a

    Adam Firen

    12/01/2020, 6:37 PM
    I have joined the channel to have a chat about graphql support for ktor, would this be the right place to open a thread about it?
    r
    m
    • 3
    • 10
  • a

    Adam Firen

    12/01/2020, 6:57 PM
    I found few messages about graphql in ktor in this channel so here it goes… I have created an example using ktor for graphql-kotlin library here https://github.com/ExpediaGroup/graphql-kotlin/pull/951 it was merged in but there is still some work to do to support subscriptions. It’s where I started thinking, there are a few initiatives to implement graphql in kotlin which take slightly different approaches. I would like to personally get involved into one of them. Before I make my decision I would like to know, though, if ktor team has any favourite approach or if it is planning to provide their own implementation?
    o
    • 2
    • 2
  • s

    spierce7

    12/01/2020, 7:08 PM
    Is Ktor 1.4.1 compatible with Kotlin 1.4.20?
    j
    r
    • 3
    • 3
  • t

    tylerwilson

    12/01/2020, 7:55 PM
    Just an FYI: I just tried to update to Ktor 1.4.3 (got the announcement email), and it breaks some of our APIs due to the fact that it no longer encodes all ‘=’ in the query parameters. See here: https://github.com/ktorio/ktor/commit/a55249b7495c4f4426f458d6cb56b7122e025cb3 I agree that according to the spec this ought to work fine, and it is more of an issue on our (admittedly old) server code. But perhaps it might adversely impact others as well. Thanks.
    h
    a
    • 3
    • 3
  • u

    user

    12/02/2020, 10:45 AM
    1.4.3 Release We’ve released 1.4.3. As always, please check the change log at https://ktor.io/changelog/
    🎉 8
    :ktor: 14
    v
    e
    a
    • 3
    • 3
  • j

    John O'Reilly

    12/03/2020, 4:19 PM
    Should Ktor 1.4.3 work with Kotlin/Native and, if so, are there particular associated dependencies it needs? I see for example it still has transitive dependency to
    v1.3.9-native-mt-2
    of kotlinx coroutines whereas I'm using
    1.4.2-native-mt
    (which is working btw with Ktor 1.4.0)
    • 1
    • 1
  • s

    Sheroz Nazhmudinov

    12/03/2020, 4:33 PM
    Hi 👋 I’m playing with ktor on Android platform, to see how it works. I managed to test the
    get
    request, but i’m hitting
    MissingFieldException
    when trying out
    post
    . Can smbd please check what I might be doing wrong? Thanks in advance! Some code snippets:
    @Serializable
    data class RegistrationParams(
        val name: String,
        val job: String
    )
    
    @Serializable
    data class RegistrationResponse(
        @SerialName("name") val name: String,
        @SerialName("job") val job: String,
        @SerialName("id") val id: String,
        @SerialName("createdAt") val createdAt: String
    )
    
    val httpClient = HttpClient(Android) {
            install(JsonFeature) {
                val json = Json { ignoreUnknownKeys = true }
                serializer = KotlinxSerializer(json = json)
            }
        }
    
    suspend fun samplePostRequest(): RegistrationResponse = <http://client.post|client.post>(
            urlString = "<https://reqres.in/api/users>",
        ) {
            body = Json.encodeToString(
                RegistrationParams.serializer(),
                RegistrationParams(
                    name = "Neo",
                    job = "The Chosen One"
                )
            )
        }
    The error message says:
    Field 'name' is required, but it was missing
    j
    • 2
    • 4
  • m

    Marc Knaup

    12/03/2020, 5:42 PM
    What’s the reason Ktor is no longer published through Bintray? Was it too slow/unreliable?
    c
    • 2
    • 4
  • r

    Rafal

    12/04/2020, 9:00 AM
    Hi folks. I wanted to use
    kotlinx.serialization
    in
    ContentNegotiation
    and I can’t find the artifact containing that
    serialization()
    method as stated in the ktor docs
    install(ContentNegotiation) {
        serialization()
    }
    Do you know which artifact I need to include in the gradle file?
    j
    d
    • 3
    • 6
  • p

    Paul Woitaschek

    12/04/2020, 9:15 AM
    Am I correct that ktor sockets can not be used on ios? https://ktor.io/docs/servers-raw-sockets.html#client These examples show a
    ActorSelectorManager
    which I can only find on the jvm
    o
    • 2
    • 6
  • m

    mytrile

    12/04/2020, 8:25 PM
    Hi, I'm trying out ktor and reading the HTTP API—Ktor 1.4.0, but when I make post request it gives me Caused by: io.ktor.features.CannotTransformContentToTypeException: Cannot transform this request's content to com.example.LoginRegister
    r
    • 2
    • 7
  • r

    robnik

    12/05/2020, 3:47 AM
    I'm always running my Kotlin web stuff behind nginx, but the nginx seems to do nothing for me. It's just more annoying configuration. Do you think I could run Ktor on ports 80 and 443 and have it be the main web server?
    j
    c
    +2
    • 5
    • 4
  • h

    Hamza GATTAL

    12/06/2020, 4:38 PM
    Hi everyone I'm using jwt auth I don't understand how I set the values of domain, audience and realm in the application.conf Should anyone explain to me how get that values and set it in my project
    :kotlin-intensifies: 2
    m
    • 2
    • 1
  • s

    spierce7

    12/07/2020, 3:44 AM
    I’m having trouble using ktor http client 1.4.3 in the common layer. I can’t resolve the code in the IDE. Downgrading to 1.4.2 fixes it.
    e
    • 2
    • 19
  • a

    Alexander Weickmann

    12/07/2020, 9:15 AM
    Hi all, we built an API that allows the upload of JSON data. We would like to limit the request body size to a fixed number of MB. we didn't find any such feature in ktor, nor in the underlying Jetty engine (not for json content type). So we implemented our own function that would parse the input stream and stop once it is too many bytes As this is using blocking API, we are not sure whether this will cause problems down the road? We wonder how ktor itself receives json in a non-blocking way?
    suspend fun PipelineContext<Unit, ApplicationCall>.receiveCarefully(): String? =
            @Suppress("BlockingMethodInNonBlockingContext")
            withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
                val bodyBuilder = StringBuilder()
                val stream = call.receiveStream()
                stream.reader().use { reader ->
                    do {
                        val chars = CharArray(8192)
                        val numRead = reader.read(chars)
                        if (numRead > 0) {
                            bodyBuilder.append(String(chars, 0, numRead))
                            if (bodyBuilder.length > AppConfig.maxUploadChars) {
                                return@withContext null
                            }
                        }
                    } while (numRead > -1)
                    bodyBuilder.toString()
                }
            }
    j
    • 2
    • 7
  • s

    Sourabh Rawat

    12/07/2020, 9:43 AM
    I have this webscocket code:
    fun openWebSocket(scope: CoroutineScope = GlobalScope, consumer: JsonRpcListener) {
            scope.launch {
                <http://httpClient.ws|httpClient.ws>(method = HttpMethod.Get, host = host, port = port, path = path) {
                    incoming.consumeAsFlow()
                        .onEach { consumer.run(it) }
                        .collect()
                }
            }
        }
    So how do I close the ws from client side?
    e
    • 2
    • 4
  • g

    Gus

    12/07/2020, 12:07 PM
    Hi folks. I'm using Ktor to connect to a WebSocket server using the OkHTTP engine. Does Ktor proactively detect and terminate broken connections using WebSocket pings? If not, how can I do it manually? I can't find any docs on this.
    • 1
    • 1
  • s

    Sourabh Rawat

    12/08/2020, 12:39 PM
    fun main() = runBlocking {
        val httpClient = HttpClient {
            install(Logging) {
                level = LogLevel.ALL
            }
            @OptIn(KtorExperimentalAPI::class)
            install(WebSockets)
            expectSuccess = false
            install(JsonFeature) {
                @OptIn(KtorExperimentalAPI::class)
                acceptContentTypes = listOf(ContentType("application", "json-rpc"))
                serializer = KotlinxSerializer()
            }
        }
        val wss =httpClient.webSocketSession(method = HttpMethod.Get, host = "127.0.0.1", port = 6800, path = "/jsonrpc")
        wss.close()
    }
    this does not stop the program. what am I doing wrong?
    • 1
    • 3
  • b

    Big Chungus

    12/08/2020, 8:14 PM
    What do you guys use for mongodb in your ktor apps?
    m
    v
    • 3
    • 14
  • c

    christophsturm

    12/08/2020, 10:29 PM
    in the ContentNegotiation source there is a comment saying
    // Respond with "415 Unsupported Media Type" if content cannot be transformed on receive
    but when i send a json body to my server where one field name is misspelled, I get a 500 internal server error reply instead.
    • 1
    • 2
  • c

    christophsturm

    12/09/2020, 10:43 AM
    is the
    jvmTest
    gradle task supposed to finish without errors? I’m getting a lot of timeouts (on macOs)
    h
    • 2
    • 15
  • h

    hhariri

    12/09/2020, 12:17 PM
    <!here> Folks, as some of you may have heard, GitHub announced support for Discussion forums. On the Ktor team we use SO as the main forum, and then there are peer to peer mediums such as this channel. How would folks feel about opening up discussions on GitHub?
    🤷‍♂️ 19
    👍 35
    b
    j
    +6
    • 9
    • 18
  • h

    Hamza GATTAL

    12/09/2020, 10:13 PM
    After complete coding, the author said Run server and test with post-man What is post-man and how i can use it https://medium.com/@er.imran4u/kotlin-ktor-with-jwt-authentication-ed78251629c2
    a
    • 2
    • 3
Powered by Linen
Title
h

Hamza GATTAL

12/09/2020, 10:13 PM
After complete coding, the author said Run server and test with post-man What is post-man and how i can use it https://medium.com/@er.imran4u/kotlin-ktor-with-jwt-authentication-ed78251629c2
a

Alejandro Rios

12/09/2020, 11:22 PM
This https://www.postman.com/downloads/
It's an app that lets you test endpoints
h

Hamza GATTAL

12/09/2020, 11:38 PM
Wow time to something new Thanks brother
View count: 3