Browse Source

解决大华API因鉴权失败导致的请求错误;

master
luyan 2 years ago
parent
commit
6add8666de
  1. 10
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/VideoServiceImpl.java

10
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(); 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("设备通道列表为空"); log.error("设备通道列表为空");
channelList = Collections.emptyList(); channelList = Collections.emptyList();
} }
iClient = null;
return channelList; return channelList;
} }
@ -130,6 +127,9 @@ public class VideoServiceImpl implements VideoService {
realtimeBody = String.format(realtimeBody, channelCode, streamType, type); realtimeBody = String.format(realtimeBody, channelCode, streamType, type);
log.info("请求参数:{}", realtimeBody); log.info("请求参数:{}", realtimeBody);
realtimeRequest.body(realtimeBody); realtimeRequest.body(realtimeBody);
if (null == iClient) {
iClient = new DefaultClient(host, username, password, clientId, clientSecret);
}
String realtimeResponse = iClient.doAction(realtimeRequest); String realtimeResponse = iClient.doAction(realtimeRequest);
String url = null; String url = null;
try { try {
@ -143,6 +143,8 @@ public class VideoServiceImpl implements VideoService {
throw new RuntimeException("response format error"); throw new RuntimeException("response format error");
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} finally {
iClient = null;
} }
return url; return url;
} }

Loading…
Cancel
Save