From f646c28151611a8fdbfbf0f722f5a40ace7c5ba2 Mon Sep 17 00:00:00 2001 From: 0xb00bface <0xboobface@gmail.com> Date: Sat, 23 Jan 2021 22:57:59 +0100 Subject: [PATCH] Add setting for playlist request timeout --- client/src/main/java/ctbrec/ui/settings/SettingsTab.java | 5 +++++ common/src/main/java/ctbrec/Settings.java | 1 + .../ctbrec/recorder/download/hls/AbstractHlsDownload.java | 5 +++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/client/src/main/java/ctbrec/ui/settings/SettingsTab.java b/client/src/main/java/ctbrec/ui/settings/SettingsTab.java index c7b9539c..a432833f 100644 --- a/client/src/main/java/ctbrec/ui/settings/SettingsTab.java +++ b/client/src/main/java/ctbrec/ui/settings/SettingsTab.java @@ -135,6 +135,7 @@ public class SettingsTab extends Tab implements TabSelectionListener { private SimpleIntegerProperty postProcessingThreads; private IgnoreList ignoreList; private Label restartNotification; + private SimpleIntegerProperty playlistRequestTimeout; public SettingsTab(List sites, Recorder recorder) { this.sites = sites; @@ -193,6 +194,7 @@ public class SettingsTab extends Tab implements TabSelectionListener { useHlsdl = new SimpleBooleanProperty(null, "useHlsdl", settings.useHlsdl); hlsdlExecutable = new SimpleFileProperty(null, "hlsdlExecutable", settings.hlsdlExecutable); recentlyWatched = new SimpleBooleanProperty(null, "recentlyWatched", settings.recentlyWatched); + playlistRequestTimeout = new SimpleIntegerProperty(null, "playlistRequestTimeout", settings.playlistRequestTimeout); } private void createGui() { @@ -277,6 +279,9 @@ public class SettingsTab extends Tab implements TabSelectionListener { ) ), Category.of("Advanced / Devtools", + Group.of("Networking", + Setting.of("Playlist request timeout (ms)", playlistRequestTimeout, "Timeout in ms for playlist requests") + ), Group.of("Logging", Setting.of("Log FFmpeg output", logFFmpegOutput, "Log FFmpeg output to files in the system's temp directory") ), diff --git a/common/src/main/java/ctbrec/Settings.java b/common/src/main/java/ctbrec/Settings.java index 9fb7a42a..59c1eac5 100644 --- a/common/src/main/java/ctbrec/Settings.java +++ b/common/src/main/java/ctbrec/Settings.java @@ -113,6 +113,7 @@ public class Settings { public String password = ""; @Deprecated public String postProcessing = ""; + public int playlistRequestTimeout = 2000; public int postProcessingThreads = 2; public List postProcessors = new ArrayList<>(); public String proxyHost; diff --git a/common/src/main/java/ctbrec/recorder/download/hls/AbstractHlsDownload.java b/common/src/main/java/ctbrec/recorder/download/hls/AbstractHlsDownload.java index 0665ecf6..3cefa29e 100644 --- a/common/src/main/java/ctbrec/recorder/download/hls/AbstractHlsDownload.java +++ b/common/src/main/java/ctbrec/recorder/download/hls/AbstractHlsDownload.java @@ -230,7 +230,7 @@ public abstract class AbstractHlsDownload extends AbstractDownload { addHeaders(builder, Optional.ofNullable(model).map(Model::getHttpHeaderFactory).map(HttpHeaderFactory::createSegmentPlaylistHeaders).orElse(new HashMap<>()), model); Request request = builder.build(); - try (Response response = client.execute(request, 2000)) { + try (Response response = client.execute(request, config.getSettings().playlistRequestTimeout)) { if (response.isSuccessful()) { consecutivePlaylistTimeouts = 0; String body = response.body().string(); @@ -253,7 +253,8 @@ public abstract class AbstractHlsDownload extends AbstractDownload { throw new HttpException(response.code(), response.message()); } } catch (SocketTimeoutException e) { - LOG.debug("Playlist request timed out for model {} {} time{}", model, ++consecutivePlaylistTimeouts, (consecutivePlaylistTimeouts > 1) ? 's' : ""); + LOG.debug("Playlist request timed out ({}ms) for model {} {} time{}", config.getSettings().playlistRequestTimeout, model, + ++consecutivePlaylistTimeouts, (consecutivePlaylistTimeouts > 1) ? 's' : ""); // times out, return an empty playlist, so that the process can continue without wasting much more time recordingEvents.add(RecordingEvent.of("Playlist request timed out " + consecutivePlaylistTimeouts)); throw new PlaylistTimeoutException(e);