Is there any reason why if a client sends a form b...
# ktor
d
Is there any reason why if a client sends a form body to a Ktor server, sometimes it receives it, and some times it ends up null..? (I'm using
receiveParameters()
and
parameters["paramName"]
...). Could it be connectivity issues that don't send the full json body (it's a bit big in some cases...) and Ktor just ignores it instead of failing? Is there any way of printing the raw request in such cases where an expected key is omitted to be able to better analyze the problem?
a
So a client sends a form or a JSON data in the body?
d
A form with two jsons under two keys
In the body of the request
a
Can you reproduce this problem locally?
d
No... it's been a while we've been having this on our production servers... most of the api failures we have a due to Kotlinx Serialization not receiving a full json...
I'm not sure, but a hunch might be that the Android device sending a large json body with a bad connection doesn't complete sending the request... and Ktor just passes that over either as partial jsons (which I didn't mention in the original question, but also happens), or just a null... like in the question (which I REALLY wouldn't expect from Ktor that it should return 200 for such a request...)
That's why I'd like some tool to try to see the raw request, to know what actually comes from the device BEFORE Ktor starts processing it.
I'd just want to print it out when there's a problem with what I received, though... (otherwise, our logs aggregator will start getting huge amounts of logs...)
a
You can use some HTTP sniffer to observe raw requests.
d
HTTP sniffer in Kubernetes?
When I need to only listen to invalid requests?
How will the sniffer know what to report on amongst the thousands of good requests?
(especially when they also return 200)
a
I think most of them allow to filter HTTP traffic based on conditions
d
I could try finding one, I guess that Ktor doesn't have such capabilites then?