HttpReaderPolicy

data class HttpReaderPolicy(val connectTimeout: Duration = 10.seconds, val readTimeout: Duration = 10.seconds, val maxReconnects: Int = 5, val initialBackoff: Duration = 500.milliseconds, val maxBackoff: Duration = 4.seconds)

How long the HTTP reader, KtorMediaIo, waits for a server, and how it recovers when a connection drops.

The reader enforces these limits itself, with coroutine timeouts, so they hold with every Ktor engine and with a client that the application supplies. A wait that passes its limit fails with KtorMediaIoException, and during a read that failure makes the reader reconnect.

Constructors

Link copied to clipboard
constructor(connectTimeout: Duration = 10.seconds, readTimeout: Duration = 10.seconds, maxReconnects: Int = 5, initialBackoff: Duration = 500.milliseconds, maxBackoff: Duration = 4.seconds)

Properties

Link copied to clipboard

The longest wait for the connection and the response headers of one request. A seek sends a new request, so this limits a seek too.

Link copied to clipboard

The wait before the first reconnect of a read. Each later wait is twice as long.

Link copied to clipboard

The longest wait between two reconnects.

Link copied to clipboard

How many times one read may reconnect after a failure, a read timeout or a response that ended early. Each reconnect is a Range request at the byte the reader reached. Zero turns recovery off. The count belongs to one read, so a connection that drops now and then never uses it up.

Link copied to clipboard

The longest wait for the next bytes of a response that has started.