dm6801
11/14/2020, 12:33 PMdf
11/14/2020, 9:10 PMcisimon7
11/14/2020, 9:48 PMgbaldeck
11/14/2020, 11:29 PMgradlew run
it sees the jvm args and starts just fine, it's only through intellij that theres a problem. Does anyone know how to fix this issue?dm6801
11/15/2020, 1:14 PMwilliam
11/16/2020, 12:17 AMJsonFeature
, but I would like to wrap my return types with a Result
sealed class type of thing instead of exceptions when a network error occurs - any suggestions for going forward with this?dagomni
11/16/2020, 12:47 PMkotlin.Error: Ktor native HttpClient requires kotlinx.coroutines version with `native-mt` suffix (like `1.3.9-native-mt`). Consider checking the dependencies.
Has anyone else experienced this? It happens on iOS with Ktor 1.4.1, 1.4.2; coroutines 1.3.9-native-mt, 1.3.9-native-mt-2arthur_sav
11/16/2020, 6:10 PMaleksey.tomin
11/17/2020, 10:40 AMval response = <http://httpClient.post|httpClient.post><T>(url) {
contentType(ContentType.Application.Json)
body = "some json"
}
This code executed on windows ~1 sec but on macOS - first request < 1 sec but next ~ 15 sec.
kotlin 1.4.10, ktor 1.4.2, io.ktor:ktor-client-curl
and others.
How can I look up a problem?df
11/17/2020, 5:08 PMval content = """
{"identifier":"cdp_9055274"}
{"identifier":"cdp_9111757"}
{"identifier":"cdp_9135021"}
""".trimIndent()
val response = httpClient.patch<String> {
url("/api/rest/v1/products")
header("Authorization", "Bearer ${token.accessToken}")
contentType(ContentType("application", "vnd.akeneo.collection+json"))
body = content
}
and it seems like regardless of what I'm writing into the body (the string, TextContent / ByteArrayContent), the body is always serialized into json again.Alexander Black
11/17/2020, 7:02 PMsuspend fun HttpClient.downloadFile(
output: File,
downloadUrl: Url,
md5Hash: String
): Flow<DownloadResult> {
return flow {
try {
val response = get<HttpResponse> { url(downloadUrl) }
val data = ByteArray(response.contentLength()?.toInt() ?: 0)
var offset = 0
do {
val progress = (offset.toDouble() / data.size) * 100
emit(DownloadResult.Progress(progress))
val currentRead = response.content.readAvailable(data, offset, data.size)
offset += currentRead
} while (currentRead > 0)
if (response.status.isSuccess()) {
if (data.md5().hex == md5Hash) {
output.write(data)
emit(DownloadResult.Success)
} else {
emit(DownloadResult.ErrorCorruptFile)
}
} else {
emit(DownloadResult.ErrorBadResponseCode(response.status.value))
}
} catch (e: TimeoutCancellationException) {
emit(DownloadResult.ErrorRequestTimeout("Connection timed out", e))
} catch (t: Throwable) {
emit(DownloadResult.Error("Failed to connect", t))
}
}
}
The problem is that the response.content.readAvailable()
method always seems to read the whole file at once without chunking it up, which means my progress emission only gets outputted once. I’m wondering if there’s something I’m doing wrong here? or if that’s normal behaviour? Also as a side note the file I’m testing on is 25MB so it should emit a few times I’d think.Big Chungus
11/18/2020, 10:12 AMkeochris
11/18/2020, 12:05 PMJanez Kolar
11/19/2020, 8:21 AMrouting {
val wsConnections = Collections.synchronizedSet(LinkedHashSet<DefaultWebSocketSession>())
webSocket("/chat") { // this: DefaultWebSocketSession
wsConnections += this
try {
while (true) {
val frame = incoming.receive()
when (frame) {
is Frame.Text -> {
val text = frame.readText()
// Iterate over all the connections
for (conn in wsConnections) {
conn.outgoing.send(Frame.Text(text))
}
}
}
}
} finally {
wsConnections -= this
}
}
}
Satyam Agarwal
11/19/2020, 1:04 PMget("/") {
call.respondTextWriter {
withContext(IO) { TextFormat.write004(this@respondTextWriter, CollectorRegistry.defaultRegistry.metricFamilySamples()) }
}
}
Exception in thread "eventLoopGroupProxy-3-1" kotlinx.coroutines.CoroutinesInternalError: Fatal exception in coroutines machinery for DispatchedContinuation[UnsafeBlockingTrampoline@381151be, Continuation at io.ktor.utils.io.jvm.javaio.OutputAdapter$loop$1.loop(Blocking.kt:311)@33f7436b]. Please read KDoc to 'handleFatalException' method and report this incident to maintainers
at kotlinx.coroutines.DispatchedTask.handleFatalException$kotlinx_coroutines_core(DispatchedTask.kt:144)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:115)
at io.ktor.utils.io.jvm.javaio.UnsafeBlockingTrampoline.dispatch(Blocking.kt:296)
at kotlinx.coroutines.internal.DispatchedContinuation.resumeWith(DispatchedContinuation.kt:184)
at io.ktor.utils.io.jvm.javaio.BlockingAdapter$end$1.resumeWith(Blocking.kt:163)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at io.ktor.utils.io.jvm.javaio.UnsafeBlockingTrampoline.dispatch(Blocking.kt:296)
at kotlinx.coroutines.internal.DispatchedContinuation.resumeWith(DispatchedContinuation.kt:184)
at io.ktor.utils.io.internal.CancellableReusableContinuation.resumeWith(CancellableReusableContinuation.kt:93)
at io.ktor.utils.io.ByteBufferChannel.resumeWriteOp(ByteBufferChannel.kt:2258)
at io.ktor.utils.io.ByteBufferChannel.bytesRead(ByteBufferChannel.kt:929)
at io.ktor.utils.io.ByteBufferChannel.consumed(ByteBufferChannel.kt:1953)
at io.ktor.server.netty.cio.NettyResponsePipeline$processBodyFlusher$2.invokeSuspend(NettyResponsePipeline.kt:305)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.ktor.server.netty.EventLoopGroupProxy$Companion$create$factory$1$1.run(NettyApplicationEngine.kt:215)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.ClassCastException: class kotlin.coroutines.jvm.internal.CompletedContinuation cannot be cast to class kotlinx.coroutines.internal.DispatchedContinuation (kotlin.coroutines.jvm.internal.CompletedContinuation and kotlinx.coroutines.internal.DispatchedContinuation are in unnamed module of loader 'app')
at kotlinx.coroutines.CoroutineDispatcher.releaseInterceptedContinuation(CoroutineDispatcher.kt:104)
at kotlin.coroutines.jvm.internal.ContinuationImpl.releaseIntercepted(ContinuationImpl.kt:118)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:39)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
... 22 more
`
Robert Jaros
11/19/2020, 3:07 PMkotlinx-coroutines-1.4.1-native-mt
has just been released, when can we expect new Ktor release, with coroutines 1.4 and the fix for KTOR-1286?okaymak
11/19/2020, 7:30 PMclient.submitFormWithBinaryData {
url { encodedPath = "my_url" }
formData {
append("my_key", "my_key_value")
}
}
Bu then get an error from kotlinx serialization:
kotlinx.serialization.SerializationException: Serializer for class 'MultiPartFormDataContent' is not found.
What am I missing here?Davide Giuseppe Farella
11/20/2020, 4:06 PMdefaultRequest { }
and I want a parameter to be used only for some path, what’s the best way?
Details in threadJoost Klitsie
11/22/2020, 9:38 AMrouting {
withRole(ADMIN) {
route("admin_only_route") {
}
withRole(USER) {
route("special_route") {
}
}
}
}
Azur Haljeta
11/23/2020, 9:30 AMaleksey.tomin
11/24/2020, 2:55 AMapp.run()
https://github.com/alekseytomin/coroutines-problem/pull/1
It’s a ktor’s bug? Or coroutinue’s bug?manlan
11/24/2020, 5:41 PMapplication.conf
from a non-Ktor object class?Nish Patel
11/25/2020, 6:21 AMmmaillot
11/25/2020, 9:35 PMcall.respond(HttpStatusCode.NoContent, Unit)
I have {}
in the content.Cicero
11/26/2020, 12:50 AM@Deprecated("This is going to become internal. Use Pipeline.execute() instead.")
public fun <TSubject : Any, TContext : Any> pipelineExecutorFor(
context: TContext,
interceptors: List<PipelineInterceptor<TSubject, TContext>>,
subject: TSubject
): @Suppress("DEPRECATION") PipelineExecutor<TSubject> {
return SuspendFunctionGun(subject, context, interceptors)
}
I found that my body is being sent in halfbitkid
11/26/2020, 12:18 PMget("/test") {
call.respondTextWriter(contentType = ContentType.Text.CSV) {
repeat(100000) {
write("bla")
}
}
}
result:
Exception in thread "eventLoopGroupProxy-3-2" kotlinx.coroutines.CoroutinesInternalError: Fatal exception in coroutines machinery for DispatchedContinuation[UnsafeBlockingTrampoline@28448af8, Continuation at io.ktor.utils.io.jvm.javaio.OutputAdapter$loop$1.loop(Blocking.kt:311)@4245d158]. Please read KDoc to 'handleFatalException' method and report this incident to maintainers
at kotlinx.coroutines.DispatchedTask.handleFatalException$kotlinx_coroutines_core(DispatchedTask.kt:93)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:64)
at io.ktor.utils.io.jvm.javaio.UnsafeBlockingTrampoline.dispatch(Blocking.kt:296)
at kotlinx.coroutines.DispatchedContinuation.resumeWith(DispatchedContinuation.kt:184)
at io.ktor.utils.io.jvm.javaio.BlockingAdapter$end$1.resumeWith(Blocking.kt:163)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at io.ktor.utils.io.jvm.javaio.UnsafeBlockingTrampoline.dispatch(Blocking.kt:296)
at kotlinx.coroutines.DispatchedContinuation.resumeWith(DispatchedContinuation.kt:184)
at io.ktor.utils.io.internal.CancellableReusableContinuation.resumeWith(CancellableReusableContinuation.kt:93)
at io.ktor.utils.io.ByteBufferChannel.resumeWriteOp(ByteBufferChannel.kt:2258)
at io.ktor.utils.io.ByteBufferChannel.bytesRead(ByteBufferChannel.kt:929)
at io.ktor.utils.io.ByteBufferChannel.consumed(ByteBufferChannel.kt:1953)
at io.ktor.server.netty.cio.NettyResponsePipeline$processBodyFlusher$2.invokeSuspend(NettyResponsePipeline.kt:305)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.ktor.server.netty.EventLoopGroupProxy$Companion$create$factory$1$1.run(NettyApplicationEngine.kt:215)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.ClassCastException: class kotlin.coroutines.jvm.internal.CompletedContinuation cannot be cast to class kotlinx.coroutines.DispatchedContinuation (kotlin.coroutines.jvm.internal.CompletedContinuation and kotlinx.coroutines.DispatchedContinuation are in unnamed module of loader 'app')
at kotlinx.coroutines.CoroutineDispatcher.releaseInterceptedContinuation(CoroutineDispatcher.kt:103)
at kotlin.coroutines.jvm.internal.ContinuationImpl.releaseIntercepted(ContinuationImpl.kt:118)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:39)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:55)
... 22 more
bitkid
11/26/2020, 2:43 PMRobert Wijas
11/26/2020, 5:38 PMByteReadChannel
(I just need to save them in local file storage) but looks like ktor is running those through json parsing as well (probably because content type is application/json
). This results in an exception, because there’s not enough information to deserialize response data. Any hints? Or should I just file a github issue? Thanks!Marcin Wisniowski
11/26/2020, 11:16 PMJérôme Gully
11/27/2020, 2:47 PM"users/{name}/commits"
, is there something in Ktor to handle this ? For the moment I use `"users/{name}/commits".replace("{name}", "Jérôme")`🙃
Retrofit handle it like this :
@GET("users/{name}/commits")
Call<List<Commit>> getCommitsByName(@Path("name") String name);
Jérôme Gully
11/27/2020, 2:47 PM"users/{name}/commits"
, is there something in Ktor to handle this ? For the moment I use `"users/{name}/commits".replace("{name}", "Jérôme")`🙃
Retrofit handle it like this :
@GET("users/{name}/commits")
Call<List<Commit>> getCommitsByName(@Path("name") String name);
mmaillot
11/27/2020, 2:51 PMJérôme Gully
11/27/2020, 4:45 PMmmaillot
11/27/2020, 5:03 PM