diff --git a/common/src/main/java/ctbrec/recorder/download/dash/DashDownload.java b/common/src/main/java/ctbrec/recorder/download/dash/DashDownload.java index 515e5640..a9055d33 100644 --- a/common/src/main/java/ctbrec/recorder/download/dash/DashDownload.java +++ b/common/src/main/java/ctbrec/recorder/download/dash/DashDownload.java @@ -81,14 +81,22 @@ public class DashDownload extends AbstractDownload { .header("Connection", "keep-alive") .build(); // @formatter:on LOG.trace("Loading manifest {}", url); - // TODO try 10 times - try (Response response = httpClient.execute(request)) { - if (response.isSuccessful()) { - return response.body().string(); - } else { - throw new HttpException(response.code(), "Couldn't load manifest: " + response.message()); + for (int tries = 1; tries <= 10; tries++) { + try (Response response = httpClient.execute(request)) { + if (response.isSuccessful()) { + return response.body().string(); + } else { + HttpException httpException = new HttpException(response.code(), "Couldn't load manifest: " + response.message()); + if (tries == 10) { + throw httpException; + } else { + LOG.debug("Couldn't load manifest", httpException); + waitSomeTime(100 * tries); + } + } } } + throw new IOException("Couldn't load manifest"); } private int downloadSegments(MPDtype mpd, AdaptationSetType adaptationSet, boolean isVideo) throws IOException {