diff --git a/apps/third/dahua.py b/apps/third/dahua.py index 59bc90c5..b1103f1d 100644 --- a/apps/third/dahua.py +++ b/apps/third/dahua.py @@ -30,7 +30,7 @@ class DhClient: if settings.DAHUA_ENABLED: self.client_id = client_id self.client_secret = client_secret - self.headers = {} + self.headers = {"Connection": "close"} self.isGetingToken = False self.isRuning = True self.token = None @@ -68,7 +68,7 @@ class DhClient: self.isRuning = False # self.t.join() - def request(self, url: str, method: str, params=dict(), json=dict(), timeout=10, + def request(self, url: str, method: str, params=dict(), json=dict(), timeout=120, file_path_rela=None, raise_exception=True): if not settings.DAHUA_ENABLED: raise ParseError('大华对接未启用') diff --git a/apps/third/speaker.py b/apps/third/speaker.py index 208d66a2..83b62f82 100644 --- a/apps/third/speaker.py +++ b/apps/third/speaker.py @@ -29,7 +29,7 @@ class SpClient: return None self.username = username self.password = password - self.headers = {} + self.headers = {"Connection": "close"} self.isGetingToken = False self.isRuning = True self.t = None # 线程 @@ -78,7 +78,7 @@ class SpClient: self.isRuning = False # self.t.join() - def request(self, url: str, method: str, params=dict(), json=dict(), timeout=10, + def request(self, url: str, method: str, params=dict(), json=dict(), timeout=120, file_path_rela=None, raise_exception=True): if not settings.SP_ENABLED: raise ParseError('音响对接未启用') diff --git a/apps/third/xunxi.py b/apps/third/xunxi.py index 4cfe2b7a..7afc35b2 100644 --- a/apps/third/xunxi.py +++ b/apps/third/xunxi.py @@ -26,6 +26,7 @@ class XxClient: self.licence = licence self.username = username self.isGetingToken = False + self.headers = {"Connection": "close"} self.isRuning = True self.token = '' self.log = {} @@ -38,7 +39,7 @@ class XxClient: 'licence': self.licence } try: - r = requests.post(json=json, url=settings.XX_BASE_URL + '/getAccessTokenV2', verify=False, timeout=20) + r = requests.post(json=json, url=settings.XX_BASE_URL + '/getAccessTokenV2', verify=False, timeout=120) ret = r.json() if ret.get('errorCode', 1) == 0: self.token = ret['data']['token'] @@ -51,7 +52,7 @@ class XxClient: json = { 'licence': self.licence } - r = requests.post(json=json, url=settings.XX_BASE_URL + '/getAccessTokenV2', verify=False, timeout=20) + r = requests.post(json=json, url=settings.XX_BASE_URL + '/getAccessTokenV2', verify=False, timeout=120) ret = r.json() if ret.get('errorCode', 1) == 0: self.isGetingToken = False @@ -88,7 +89,7 @@ class XxClient: break else: r = getattr(requests, method)('{}{}'.format(settings.XX_BASE_URL, url), - params=params, json=json, timeout=timeout, verify=False) + headers=self.headers, params=params, json=json, timeout=timeout, verify=False) # if settings.DEBUG: # print_roundtrip(r) ret = r.json()