rsetkus
10/24/2020, 7:36 PMio.ktor.client.call.NoTransformationFoundException: No transformation found: class io.ktor.utils.io.ByteChannelKt$ByteChannel$1 (Kotlin reflection is not available) -> class xxx.YYY (Kotlin reflection is not available)
with response from <https://XXX>:
status: 200 OK
response headers:
cache-control: max-age=600
, connection: keep-alive
, content-type: application/json;charset=utf-8
at io.ktor.client.call.HttpClientCall.receive(HttpClientCall.kt:84)
ursus
10/24/2020, 11:48 PMHyun
10/25/2020, 4:31 PM@Api
interface SampleApi {
suspend fun getGreeting(name: String, job: String): String
}
client
inline fun <reified API> api(baseUrl: String = serverUrl): API = client.create(baseUrl)
scope.launch {
api<SampleApi>().getGreeting("Hyun", "Programmer")
}
backend
class SampleController : SampleApi {
override suspend fun getGreeting(name: String, job: String): String = "Hello $name($job)"
}
install(SimpleFeature) {
routing {
+SampleController()
}
}
Sourabh Rawat
10/26/2020, 10:57 AMSerializer for class 'ApiResponse' is not found
@Serializable
data class ApiResponse<T>(
val result: T? = null,
val error: ApiError? = null
)
call.respond(ApiResponse(result = gameEngine.newGame()))
Please help.
Json.encodeToString(..) works fine.
ktor config:
fun Application.mainModule() {
install(ContentNegotiation) {
json()
}
...
}
Using ktor 1.4.1 and serialization 1.0.0rnett
10/27/2020, 1:04 AMnapperley
10/27/2020, 3:34 AMHttpClient
using this project: https://gitlab.com/napperley/openfaas-weather-samplealeksey.tomin
10/27/2020, 5:10 AMContentEncoding {
gzip()
}
But the server team says that request body not in gzip.Dario Pellegrini
10/27/2020, 1:19 PMNikky
10/27/2020, 3:49 PMFail to fetch
in browser tests to localhost
seems to be somehow Access-Control-Allow-Origin
related
can i ignore this or force the browser to ignore this with ktor-client ?Andrew Gazelka
10/28/2020, 12:54 AMclient.get(url: String)
? because I am getting an Http error with ktor and no error with curl and I am really confusedJoaquim Ley
10/28/2020, 2:55 PMkotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 82: Expected string literal with quotes.
Carlos Fau
10/28/2020, 9:48 PMserialization()
but we can't find it in packages. Any help?turansky
10/30/2020, 1:45 PMHttpClient
(JS client) ?
Do I need single HttpClient
if I have single API source?
GET /api/a
GET /api/b
GET /api/c
GET /api/d
Elka
11/02/2020, 5:52 PMFeature
that parses the json, does the checking and then proceed with the response…
The problem is that I cannot call readBytes
twice. The second time it’s empty as the response has already been consumed when doing the validation. Is there any way to do it?John O'Reilly
11/03/2020, 8:12 AMinstall(CORS) {
anyHost()
header("Authorization")
}
anyone aware of any other config needed to support that?Krystian Rybarczyk
11/04/2020, 2:42 PMDenis Ambatenne
11/06/2020, 10:35 AMMoses Mugisha
11/06/2020, 7:51 PMHttpClient.setMaxRequestsQueuedPerDestination()
for the jetty engine in ktor?nrobi
11/08/2020, 2:57 PMHttpClient: REQUEST https://... failed with exception: kotlinx.coroutines.CancellationException: Engine failed
Seems to be tied to async
-await
as it works as expected with launch
subashz
11/09/2020, 12:32 PMhhariri
octylFractal
11/10/2020, 10:37 PMcall.receive()
with the jackson content negotiator, I get https://gist.github.com/octylFractal/f973cee5acd96ca757c7b6a83936800fAmritansh
11/11/2020, 1:32 AMUncaught Kotlin exception: kotlinx.coroutines.CoroutinesInternalError: Fatal exception in coroutines machinery for DispatchedContinuation[MainDispatcher, Continuation @ $postRequest$lambda-1COROUTINE$1]. Please read KDoc to 'handleFatalException' method and report this incident to maintainers
at 0 shared 0x0000000103e8730c kfun:kotlin.Error#<init>(kotlin.String?;kotlin.Throwable?){} + 124 (/Users/teamcity/buildAgent/work/cae0e6559deed4c4/runtime/src/main/kotlin/kotlin/Exceptions.kt:14:63)
at 1 shared 0x0000000103ffa913 kfun:kotlinx.coroutines.CoroutinesInternalError#<init>(kotlin.String;kotlin.Throwable){} + 115 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/Exceptions.common.kt:28:77)
at 2 shared 0x0000000104042bfa kfun:kotlinx.coroutines.DispatchedTask#handleFatalException(kotlin.Throwable?;kotlin.Throwable?){} + 938 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/internal/DispatchedTask.kt:93:22)
at 3 shared 0x00000001040427e8 kfun:kotlinx.coroutines.DispatchedTask#run(){} + 3512 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/internal/DispatchedTask.kt:64:13)
at 4 shared 0x000000010406b0f5 kfun:kotlinx.coroutines.DarwinMainDispatcher.dispatch$lambda-0#internal + 85 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/nativeDarwin/src/Dispatchers.kt:35:19)
at 5 shared 0x000000010406b4ab kfun:kotlinx.coroutines.DarwinMainDispatcher.$dispatch$lambda-0$FUNCTION_REFERENCE$43.invoke#internal + 59 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/nativeDarwin/src/Dispatchers.kt:34:51)
at 6 shared 0x000000010406b50b kfun:kotlinx.coroutines.DarwinMainDispatcher.$dispatch$lambda-0$FUNCTION_REFERENCE$43.$<bridge-UNN>invoke(){}#internal + 59 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/nativeDarwin/src/Dispatchers.kt:34:51)
at 7 shared 0x000000010406c5c4 _6f72672e6a6574627261696e732e6b6f746c696e783a6b6f746c696e782d636f726f7574696e65732d636f7265_knbridge8 + 180 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/nativeDarwin/src/Dispatchers.kt:34:51)
at 8 libdispatch.dylib 0x0000000104983dd4 _dispatch_call_block_and_release + 12
at 9 libdispatch.dylib 0x0000000104984d48 _dispatch_client_callout + 8
at 10 libdispatch.dylib 0x0000000104992de6 _dispatch_main_queue_callback_4CF + 1500
at 11 CoreFoundation 0x00007fff23bd4049 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
at 12 CoreFoundation 0x00007fff23bceca9 __CFRunLoopRun + 2329
at 13 CoreFoundation 0x00007fff23bce066 CFRunLoopRunSpecific + 438
at 14 GraphicsServices 0x00007fff384c0bb0 GSEventRunModal + 65
at 15 UIKitCore 0x00007fff48092d4d UIApplicationMain + 1621
at 16 iosApp-sample 0x0000000103b0405b main + 75 (/Users/atripathi/shared/iosApp-sample/iosApp-sample/AppDelegate.swift:4:7)
at 17 libdyld.dylib 0x00007fff5227ec25 start + 1
Caused by: kotlin.native.IncorrectDereferenceException: Trying to access top level value not marked as @ThreadLocal or @SharedImmutable from non-main thread
at 0 shared 0x0000000103e8e52d kfun:kotlin.Throwable#<init>(kotlin.String?){} + 93 (/Users/teamcity/buildAgent/work/cae0e6559deed4c4/runtime/src/main/kotlin/kotlin/Throwable.kt:23:37)
at 1 shared 0x0000000103e8741b kfun:kotlin.Exception#<init>(kotlin.String?){} + 91 (/Users/teamcity/buildAgent/work/cae0e6559deed4c4/runtime/src/main/kotlin/kotlin/Exceptions.kt:23:44)
at 2 shared 0x0000000103e875db kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 91 (/Users/teamcity/buildAgent/work/cae0e6559deed4c4/runtime/src/main/kotlin/kotlin/Exceptions.kt:34:44)
at 3 shared 0x0000000103eba3db kfun:kotlin.native.IncorrectDereferenceException#<init>(kotlin.String){} + 91 (/Users/teamcity/buildAgent/work/cae0e6559deed4c4/runtime/src/main/kotlin/kotlin/native/Runtime.kt:30:36)
at 4 shared 0x0000000103edbb61 ThrowIncorrectDereferenceException + 129 (/Users/teamcity/buildAgent/work/cae0e6559deed4c4/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt:103:11)
at 5 shared 0x0000000103fc5c89 CheckIsMainThread + 25
at 6 shared 0x00000001041a57e3 kfun:io.ktor.http.<get-HeaderFieldValueSeparators>#internal + 19 (/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-http/common/src/io/ktor/http/HeaderValueWithParameters.kt:10:9)
at 7 shared 0x00000001041a6e24 kfun:io.ktor.http.checkNeedEscape#internal + 356 (/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-http/common/src/io/ktor/http/HeaderValueWithParameters.kt:86:13)
at 8 shared 0x00000001041a65d5 kfun:io.ktor.http.HeaderValueWithParameters#toString(){}kotlin.String + 2101 (/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-http/common/src/io/ktor/http/HeaderValueWithParameters.kt:41:21)
at 9 shared 0x00000001041fb0f7 kfun:io.ktor.client.engine#mergeHeaders(io.ktor.http.Headers;io.ktor.http.content.OutgoingContent;kotlin.Function2<kotlin.String,kotlin.String,kotlin.Unit>){} + 3095 (/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-client/ktor-client-core/common/src/io/ktor/client/engine/Utils.kt:45:37)
at 10 shared 0x000000010423adfe kfun:io.ktor.client.engine.ios.IosClientEngine.$executeCOROUTINE$0#invokeSuspend(kotlin.Result<kotlin.Any?>){}kotlin.Any? + 5630 (/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-client/ktor-client-ios/darwin/src/io/ktor/client/engine/ios/IosClientEngine.kt:40:13)
at 11 shared 0x000000010423c2a4 kfun:io.ktor.client.engine.ios.IosClientEngine#execute(io.ktor.client.request.HttpRequestData){}io.ktor.client.request.HttpResponseData + 308 (/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-client/ktor-client-ios/darwin/src/io/ktor/client/engine/ios/IosClientEngine.kt:21:22)
at 12 shared 0x00000001041f813b kfun:io.ktor.client.engine.HttpClientEngine.$executeWithinCallContext$lambda-1COROUTINE$11.invokeSuspend#internal + 731 (/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-client/ktor-client-core/common/src/io/ktor/client/engine/HttpClientEngine.kt:86:13)
at 13 shared 0x0000000103eafc16 kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 758 (/Users/teamcity/buildAgent/work/cae0e6559deed4c4/runtime/src/main/kotlin/kotlin/coroutines/ContinuationImpl.kt:30:39)
at 14 shared 0x00000001040424ff kfun:kotlinx.coroutines.DispatchedTask#run(){} + 2767 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/internal/DispatchedTask.kt:39:50)
at 15 shared 0x0000000103ff5ecf kfun:kotlinx.coroutines.EventLoopImplBase#processNextEvent(){}kotlin.Long + 799 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/EventLoop.common.kt:274:18)
at 16 shared 0x000000010405a228 kfun:kotlinx.coroutines#runEventLoop(kotlinx.coroutines.EventLoop?;kotlin.Function0<kotlin.Boolean>){} + 872 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/native/src/Builders.kt:80:40)
at 17 shared 0x0000000104062b85 kfun:kotlinx.coroutines.WorkerCoroutineDispatcherImpl.start$lambda-0#internal + 389 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/native/src/Workers.kt:49:17)
at 18 shared 0x0000000104062d5b kfun:kotlinx.coroutines.WorkerCoroutineDispatcherImpl.$start$lambda-0$FUNCTION_REFERENCE$35.invoke#internal + 59 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/native/src/Workers.kt:47:24)
at 19 shared 0x0000000104062dbb kfun:kotlinx.coroutines.WorkerCoroutineDispatcherImpl.$start$lambda-0$FUNCTION_REFERENCE$35.$<bridge-UNN>invoke(){}#internal + 59 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/native/src/Workers.kt:47:24)
at 20 shared 0x0000000103ebdfe7 WorkerLaunchpad + 183 (/Users/teamcity/buildAgent/work/cae0e6559deed4c4/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt:69:54)
at 21 shared 0x0000000103fbb09f _ZN6Worker19processQueueElementEb + 3135
at 22 shared 0x0000000103fba446 _ZN12_GLOBAL__N_113workerRoutineEPv + 54
at 23 libsystem_pthread.dylib 0x00007fff524602eb _pthread_body + 126
at 24 libsystem_pthread.dylib 0x00007fff52463249 _pthread_start + 66
at 25 libsystem_pthread.dylib 0x00007fff5245f40d thread_start + 13
(lldb)
This is what my implementation looks like
fun postRequest() {
MainScope().launch {
withContext(Dispatchers.Default) {
HttpClient().post("URL"){
body = "some json"
}
}
}
}
This request is working fine for the Android application and only throws the exception in iOS. Also if I try to run HttpClient().post on the main thread, it works fine on iOS and I am successfully able to send the request.
ktorVersion = "1.4.2"
coroutinesVersion = "1.3.9-native-mt-2"dm6801
11/11/2020, 6:51 PMoverride val cookies: RequestCookies
get() = throw UnsupportedOperationException()
working as intended or should I open a youtrack bug?goto1134
11/11/2020, 7:19 PMRobert Jaros
11/11/2020, 9:46 PMjava.lang.IllegalStateException: Using blocking primitives on this dispatcher is not allowed. Consider using async channel instead or use blocking primitives in withContext(<http://Dispatchers.IO|Dispatchers.IO>) instead.
It looks like it has something to do with Jackson. Is this a known issue?Archie
11/12/2020, 8:42 AMKtor
require HttpClientEngine
but Coil
needs the OkHttpClient
itself. Is there a way to make both work together?tieskedh
11/12/2020, 5:45 PMsuspend inline fun ByteReadChannel.toFlow(): Flow<ByteArray> {
return flow {
do {
read { source, start, endExclusive ->
val array = when {
endExclusive > start -> {
val mem = source.slice(start, endExclusive - start)
val byteArray = ByteArray(mem.size.toInt())
mem.copyTo(byteArray, 0, mem.size.toInt())
byteArray
}
else -> byteArrayOf()
}
emit(array)
255
}
if (isClosedForRead) break
} while (currentCoroutineContext().isActive)
}
}
Alberto Quario
11/13/2020, 4:52 PMinstall(MicrometerMetrics) {
registry = DatadogMeterRegistry(config, Clock.SYSTEM)
...
}
Would it be possible to access and reuse the same registry for adding custom metrics in handlers?
Thanks!Rob Hurkes
11/13/2020, 7:41 PMException in thread "eventLoopGroupProxy-3-6" kotlinx.coroutines.CoroutinesInternalError: Fatal exception in coroutines machinery for DispatchedContinuation[UnsafeBlockingTrampoline@762b17ae, Continuation at <http://io.ktor.utils.io|io.ktor.utils.io>.jvm.javaio.OutputAdapter$loop$1.loop(Blocking.kt:311)@64588a54]. Please read KDoc to 'handleFatalException' method and report this incident to maintainers
.
The actual cause is further down the stack trace:
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)
I've got a minimal reproduction example up at https://github.com/rhurkes/ktor-playground/commit/989b512bd7209735fd4d223b839d20d307c533c3