Akka Http Client (request-level) Request Timeout

I really like using the request-level api for Akka Http Client but I need to set timeouts per request. I understand there are settings for idle timeout and connection timeout but not for request timeout. There’s even an issue in Akka Http open for this (https://github.com/akka/akka-http/issues/622) but it has no resolution (3+ years). Wondering if my only option is to use the connection-level api (which I don’t want)

Indeed, we didn’t get to fixing that properly yet.

As a poor-man’s workaround until we fix that issue you could use a simple request timeout, though the drawback would be that requests that time out in the queue will still be executed even if the response will be discarded afterwards.

Thank you @jrudolph for your reply. Would you mind expanding (if possible with a simple example) on your solution? I am not aware of any setting at the request-level that allows you to set a timeout.

@juanavelez just curious if you explored https://github.com/akka/akka-http/blob/acbf077fcf929e1de79ef1022a8d4d7f3a4798c2/akka-http-core/src/main/resources/reference.conf#L50?

Thank you for your reply. Unfortunately that particular property is for Servers not clients.

1 Like

Sorry missed coming back to that issue.

You might be able to use something like

Future.firstCompletedOf(Seq(
    akka.pattern.after(timeout, scheduler)(Future.failed(timedOutException)), 
    requestFuture
)