添加重试
This commit is contained in:
parent
f1db3e3d1d
commit
21f2a50952
@ -355,7 +355,7 @@ public class WvpService {
|
|||||||
schedule.cancel(true);
|
schedule.cancel(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
String token = login();
|
final String[] token = {login()};
|
||||||
Retryer<Optional<DeviceChannel>> defaultGenericRetryer = RetryerBuilder.<Optional<DeviceChannel>>newBuilder()
|
Retryer<Optional<DeviceChannel>> defaultGenericRetryer = RetryerBuilder.<Optional<DeviceChannel>>newBuilder()
|
||||||
// 异常就重试
|
// 异常就重试
|
||||||
.retryIfException()
|
.retryIfException()
|
||||||
@ -370,10 +370,11 @@ public class WvpService {
|
|||||||
if (attempt.hasException()) {
|
if (attempt.hasException()) {
|
||||||
log.info("异常 {}", attempt.getExceptionCause().getMessage());
|
log.info("异常 {}", attempt.getExceptionCause().getMessage());
|
||||||
cache.remove("token");
|
cache.remove("token");
|
||||||
|
token[0] = login();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).build();
|
}).build();
|
||||||
Optional<DeviceChannel> deviceChannel = defaultGenericRetryer.call(() -> getDeviceChannelByDeviceCode(token, deviceCode));
|
Optional<DeviceChannel> deviceChannel = defaultGenericRetryer.call(() -> getDeviceChannelByDeviceCode(token[0], deviceCode));
|
||||||
|
|
||||||
if (deviceChannel.isEmpty()) {
|
if (deviceChannel.isEmpty()) {
|
||||||
result.setResult(JsonResponse.error(MessageFormat.format("未能获取 设备: {0} 的通道信息", deviceCode)));
|
result.setResult(JsonResponse.error(MessageFormat.format("未能获取 设备: {0} 的通道信息", deviceCode)));
|
||||||
@ -384,7 +385,7 @@ public class WvpService {
|
|||||||
log.info("设备通道信息 => {}", dc);
|
log.info("设备通道信息 => {}", dc);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
StreamContent data = wvpProxyClient.playStart(token, dc.getDeviceId(), dc.getChannelId()).getData();
|
StreamContent data = wvpProxyClient.playStart(token[0], dc.getDeviceId(), dc.getChannelId()).getData();
|
||||||
log.info("实时流信息 {}", data);
|
log.info("实时流信息 {}", data);
|
||||||
|
|
||||||
String url = StringUtils.joinWith("/",
|
String url = StringUtils.joinWith("/",
|
||||||
|
Loading…
Reference in New Issue
Block a user