Is there a way to enforce a timeout for a `call.re...
# ktor
a
Is there a way to enforce a timeout for a
call.receive()
? I have been setting
requestReadTimeoutSeconds
(see post above), but realized there are only certain endpoints (from mobile clients with intermittent internet) that I care about. So I'd rather set it for each seaparate one... Any idea?
m
You could probably do
Copy code
kotlinx.coroutines.withTimeout(1000) {
            call.receive<Whatever>()
        }
a
Ah, I'll give that a try. Thanks. 🙂
🙂 1
One thing that struck me though is that this means a time-out on the entire operation. I'd be fine with it taking a long time, as long as bytes keep coming. I just want it to terminate if there's no activity. 🙂 Guess I am being demanding though. 😉