diff --git a/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/service/wvp/WvpService.java b/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/service/wvp/WvpService.java index 43e99ee..8a22872 100644 --- a/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/service/wvp/WvpService.java +++ b/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/service/wvp/WvpService.java @@ -198,7 +198,9 @@ public class WvpService { @SneakyThrows private void downloadFromPlayback(HttpServletResponse response, String token, String deviceId, String channelId, String startTime, String endTime){ - Retryer> playBackRetryer = RetryUtil.getDefaultRetryer("通过回放获取实时视频流下载"); + Retryer> playBackRetryer = RetryUtil + .getDefaultRetryerBuilder("通过回放获取实时视频流下载", 100, TimeUnit.MILLISECONDS, 5) + .build(); JsonResponse videoStreamResponse = playBackRetryer.call(() -> wvpProxyClient.playbackStart(token, deviceId, channelId, new GeneralTimeReq(startTime, endTime))); StreamContent streamContent = videoStreamResponse.getData(); String stream = streamContent.getStream(); diff --git a/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/utils/RetryUtil.java b/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/utils/RetryUtil.java index 887fb47..d2b573e 100644 --- a/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/utils/RetryUtil.java +++ b/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/utils/RetryUtil.java @@ -40,6 +40,19 @@ public class RetryUtil { return result -> result == null || (result.getCode() != 0 && result.getCode() != 200); } + public static RetryerBuilder> getDefaultRetryerBuilder(String name, int waitTime, TimeUnit waitUnit, int retryTime) { + return RetryerBuilder.>newBuilder() + // 异常就重试 + .retryIfException() + .retryIfRuntimeException() + // 重试间隔 + .withWaitStrategy(WaitStrategies.fixedWait(waitTime, waitUnit)) + // 重试次数 + .withStopStrategy(StopStrategies.stopAfterAttempt(retryTime)) + .retryIfResult(defaultRetryIf()) + .withRetryListener(defaultRetryListener(name)); + } + public static RetryerBuilder> getDefaultRetryerBuilder(String name) { return RetryerBuilder.>newBuilder() // 异常就重试 diff --git a/gb28181-wvp-proxy-starter/src/main/resources/application.yml b/gb28181-wvp-proxy-starter/src/main/resources/application.yml index 78cb19d..27e2b82 100644 --- a/gb28181-wvp-proxy-starter/src/main/resources/application.yml +++ b/gb28181-wvp-proxy-starter/src/main/resources/application.yml @@ -33,6 +33,9 @@ spring: connection-timeout: 0 ok-http: read-timeout: 0 + hc5: + connection-request-timeout: 60 + connection-request-timeout-unit: seconds media: ip: 192.168.1.241