Skip to content

Commit

Permalink
timeout fix
Browse files Browse the repository at this point in the history
  • Loading branch information
davidvng committed Aug 27, 2024
1 parent 99854a7 commit 2a3a895
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions socs/agents/http_camera/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ocs import ocs_agent, site_config
from ocs.ocs_twisted import Pacemaker, TimeoutLock
# Disable unverified HTTPS warnings (https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings)
from urllib3.exceptions import InsecureRequestWarning, ReadTimeoutError
from urllib3.exceptions import InsecureRequestWarning

requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)

Expand Down Expand Up @@ -112,8 +112,8 @@ def acq(self, session, params=None):
"userName": camera['user'],
"password": camera['password']}}}]
try:
resp = requests.post(login_url, data=json.dumps(login_payload), verify=False)
except (requests.exceptions.RequestException, ReadTimeoutError) as e:
resp = requests.post(login_url, data=json.dumps(login_payload), timeout=10, verify=False)
except BaseException as e:
self.log.error(f'{e}')
self.log.info("Unable to get response from camera.")
connected = False
Expand Down Expand Up @@ -156,11 +156,11 @@ def acq(self, session, params=None):
# If no response from camera, update connection status and continue
try:
if camera['brand'] == 'reolink':
response = requests.get(url, params=payload, stream=True, timeout=5, verify=False)
response = requests.get(url, params=payload, stream=True, timeout=10, verify=False)
elif camera['brand'] == 'acti':
response = requests.get(url, params=payload, stream=True, timeout=5)
response = requests.get(url, params=payload, stream=True, timeout=10)
connected = True
except (requests.exceptions.RequestException, ReadTimeoutError) as e:
except BaseException as e:
self.log.error(f'{e}')
self.log.info("Unable to get response from camera.")
connected = False
Expand Down

0 comments on commit 2a3a895

Please sign in to comment.