how to set timeout on a call using akka.http.javadsl.Http

47 Views Asked by At

Im on a project that is using: akka.http.javadsl.Http;

Im modyfing a piece of code that used to work well, now the problem is the http call i make need to wait more for the response, so i have to set the timeout, but even if i tried to read the documentation i didnt find any example.

        Http http = Http.get(context().system());

        CompletionStage<HttpResponse> response = http.singleRequest(HttpRequest.create(url), materializer);
        
        CompletionStage<JsonNode> result = response.thenCompose( res -> {
            if (res.status().intValue()!=200) {
                ....

i need to do something like "http.setTimeout(5000)"

or " .. = http.singleRequest(HttpRequest.create(url), materializer,5000);"

with 5000 as number of milliseconds to wait for the response before to go on timeout.

Can you help me?

0

There are 0 best solutions below