diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/VideoServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/VideoServiceImpl.java index 9a7bdf4072..ada5ba0c7c 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/VideoServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/VideoServiceImpl.java @@ -39,10 +39,6 @@ public class VideoServiceImpl implements VideoService { private final ObjectMapper mapper = new ObjectMapper(); - public VideoServiceImpl() throws ClientException { - iClient = new DefaultClient(host, username, password, clientId, clientSecret); - } - /** * 获取设备通道列表 * @@ -78,6 +74,7 @@ public class VideoServiceImpl implements VideoService { log.error("设备通道列表为空"); channelList = Collections.emptyList(); } + iClient = null; return channelList; } @@ -130,6 +127,9 @@ public class VideoServiceImpl implements VideoService { realtimeBody = String.format(realtimeBody, channelCode, streamType, type); log.info("请求参数:{}", realtimeBody); realtimeRequest.body(realtimeBody); + if (null == iClient) { + iClient = new DefaultClient(host, username, password, clientId, clientSecret); + } String realtimeResponse = iClient.doAction(realtimeRequest); String url = null; try { @@ -143,6 +143,8 @@ public class VideoServiceImpl implements VideoService { throw new RuntimeException("response format error"); } catch (IOException e) { e.printStackTrace(); + } finally { + iClient = null; } return url; }