From 4b4ad0f45fc46634314ac08b5402688b5dcff975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E5=89=8D=E6=98=8E?= <909355014@qq.com> Date: Thu, 15 Sep 2022 12:56:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=89=E6=96=B9=E6=8E=A5=E5=8F=A3=E4=BF=AE?= =?UTF-8?q?=E6=94=B9headers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/third/dahua.py | 4 ++-- apps/third/speaker.py | 4 ++-- apps/third/xunxi.py | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) 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()