Hamza GATTAL
11/27/2020, 6:48 PMNikky
11/27/2020, 8:38 PMval 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:elcamomile
11/28/2020, 4:07 PMCicero
11/28/2020, 11:30 PMio.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”}ByFloRedstone
11/29/2020, 12:09 PMrudolf.hladik
11/29/2020, 9:21 PMByFloRedstone
11/30/2020, 5:45 PMAdam Firen
12/01/2020, 6:37 PMAdam Firen
12/01/2020, 6:57 PMspierce7
12/01/2020, 7:08 PMtylerwilson
12/01/2020, 7:55 PMuser
12/02/2020, 10:45 AMJohn O'Reilly
12/03/2020, 4:19 PMv1.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)Sheroz Nazhmudinov
12/03/2020, 4:33 PMget
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
Marc Knaup
12/03/2020, 5:42 PMRafal
12/04/2020, 9:00 AMkotlinx.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?Paul Woitaschek
12/04/2020, 9:15 AMActorSelectorManager
which I can only find on the jvmmytrile
12/04/2020, 8:25 PMrobnik
12/05/2020, 3:47 AMHamza GATTAL
12/06/2020, 4:38 PMspierce7
12/07/2020, 3:44 AMAlexander Weickmann
12/07/2020, 9:15 AMsuspend 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()
}
}
Sourabh Rawat
12/07/2020, 9:43 AMfun 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?Gus
12/07/2020, 12:07 PMSourabh Rawat
12/08/2020, 12:39 PMfun 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?Big Chungus
12/08/2020, 8:14 PMchristophsturm
12/08/2020, 10:29 PM// 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.christophsturm
12/09/2020, 10:43 AMjvmTest
gradle task supposed to finish without errors? I’m getting a lot of timeouts (on macOs)hhariri
12/09/2020, 12:17 PMHamza GATTAL
12/09/2020, 10:13 PMHamza GATTAL
12/09/2020, 10:13 PMAlejandro Rios
12/09/2020, 11:22 PMHamza GATTAL
12/09/2020, 11:38 PM