Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Error when using Motion API with webhooks #1354

Closed
wohmiguel opened this issue Sep 16, 2024 · 2 comments
Closed

BUG: Error when using Motion API with webhooks #1354

wohmiguel opened this issue Sep 16, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@wohmiguel
Copy link

wohmiguel commented Sep 16, 2024

Describe the bug

Not too versed in bug-reporting, so please feel free to ask for any data. Some sensitive information has been redacted or removed but can be added back in if needed.

I have two Outdoor V1s and I'm using Home Assistant (in a VirtualBox VM) to connect it to my Apple Home setup. As of recently, I've stopped getting motion notifications and thought nothing of it since it coincided with needing to recharge my cameras, but after recharging I still haven't received any notifications so I looked through the log and received this:

[WyzeBridge] 📚 Using 'user' from local cache...
[WyzeBridge] 📚 Using 'cameras' from local cache...
[WyzeBridge] [+] Adding Driveway [WVOD1]

  • Serving Flask app 'frontend'
  • Debug mode: off
    [WyzeBridge] WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
  • Running on all addresses (0.0.0.0)
  • Running on http://127.0.0.1:5000
  • Running on http://172.30.33.0:5000
    [WyzeBridge] Press CTRL+C to quit
    [WyzeBridge] [+] Adding Entrance [WVOD1]
    [WyzeBridge] starting MediaMTX 1.1.1
    [WyzeBridge] 🎬 2 streams enabled
    [WyzeBridge] API Motion Events Enabled [interval=1.2]
    [WyzeBridge] [MOTION] Motion detected on entrance at 18:23:08
    Exception in thread Thread-1:
    Traceback (most recent call last):
    File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 466, in _make_request
    self._validate_conn(conn)
    File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 1095, in _validate_conn
    conn.connect()
    File "/usr/local/lib/python3.12/site-packages/urllib3/connection.py", line 652, in connect
    sock_and_verified = _ssl_wrap_socket_and_match_hostname(
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.12/site-packages/urllib3/connection.py", line 805, in ssl_wrap_socket_and_match_hostname
    ssl_sock = ssl_wrap_socket(
    ^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.12/site-packages/urllib3/util/ssl
    .py", line 465, in ssl_wrap_socket
    ssl_sock = ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.12/site-packages/urllib3/util/ssl
    .py", line 509, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.12/ssl.py", line 455, in wrap_socket
    return self.sslsocket_class._create(
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.12/ssl.py", line 1042, in _create
    self.do_handshake()
    File "/usr/local/lib/python3.12/ssl.py", line 1320, in do_handshake
    self._sslobj.do_handshake()
    ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate (_ssl.c:1000)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 789, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 490, in _make_request
raise new_e
urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate (_ssl.c:1000)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/requests/adapters.py", line 667, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 843, in urlopen
retries = retries.increment(
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/urllib3/util/retry.py", line 519, in increment
raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='10.0.0.xx', port=10443): Max retries exceeded with url: /endpoint/@scrypted/webhook/public/xx/xxxxxxxxxxxxxxxx/turnOn (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate (_ssl.c:1000)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
self.run()
File "/app/wyze_bridge.py", line 32, in run
self._initialize(fresh_data)
File "/app/wyze_bridge.py", line 40, in _initialize
self.streams.monitor_streams(self.rtsp.health_check)
File "/app/wyzebridge/stream.py", line 103, in monitor_streams
events.check_motion()
File "/app/wyzebridge/wyze_events.py", line 64, in check_motion
self.process_event(event)
File "/app/wyzebridge/wyze_events.py", line 58, in process_event
self.set_motion(event["device_id"], event["file_list"])
File "/app/wyzebridge/wyze_events.py", line 44, in set_motion
send_webhook("motion", stream.uri, msg, img)
File "/app/wyzebridge/webhooks.py", line 24, in send_webhook
resp = requests.post(url, headers=header, data=msg)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/requests/api.py", line 115, in post
return request("post", url, data=data, json=json, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/requests/api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/requests/adapters.py", line 698, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='10.0.0.xx', port=10443): Max retries exceeded with url: /endpoint/@scrypted/webhook/public/xx/xxxxxxxxxxxxxxxx/turnOn (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate (_ssl.c:1000)')))

Affected Bridge Version

v2.9.9

Bridge type

Home Assistant

Affected Camera(s)

Outdoor Cam V1

Affected Camera Firmware

4.17.4.427

docker-compose or config (if applicable)

ENABLE_AUDIO: true
ON_DEMAND: true
WB_AUTH: false
MOTION_API: true
MQTT: false
CAM_OPTIONS:
  - CAM_NAME: Entrance
    MOTION_WEBHOOKS: >-
      https://10.0.0.xx:10443/endpoint/@scrypted/webhook/public/xx/xxxxxxxxxxxxxxxx/turnOn
  - CAM_NAME: entrance
    MOTION_WEBHOOKS: >-
      https://10.0.0.xx:10443/endpoint/@scrypted/webhook/public/xx/xxxxxxxxxxxxxxxx/turnOn
  - CAM_NAME: Driveway
    MOTION_WEBHOOKS: >-
      https://10.0.0.xx:10443/endpoint/@scrypted/webhook/public/xx/xxxxxxxxxxxxxxxx/turnOn
  - CAM_NAME: driveway
    MOTION_WEBHOOKS: >-
      https://10.0.0.xx:10443/endpoint/@scrypted/webhook/public/xx/xxxxxxxxxxxxxxxx/turnOn
SNAPSHOT: API
MOTION_START: true
MOTION_INT: 1.2
WYZE_EMAIL: [removed]
WYZE_PASSWORD: [removed]
API_ID: [removed]
API_KEY: [removed]
NET_MODE: ANY
WB_USERNAME: [removed]
WB_PASSWORD: [removed]
SUBSTREAM: true
RTSP_FW: true
RECORD_ALL: false
@wohmiguel wohmiguel added the bug Something isn't working label Sep 16, 2024
@wohmiguel
Copy link
Author

After some digging (and some ChatGPT), I came to the conclusion that it was because the webhooks I used were using HTTPS; I used another webhook that used HTTP instead and it worked like a charm!

mrlt8 added a commit that referenced this issue Sep 16, 2024
@mrlt8
Copy link
Owner

mrlt8 commented Sep 16, 2024

Thanks, I made some changes in the dev branch to ignore self-signed certificates.

mrlt8 added a commit that referenced this issue Sep 30, 2024
sira3407 pushed a commit to sira3407/docker-wyze-bridge that referenced this issue Oct 30, 2024
- Update the devcontainer.json file to use the latest Python 3 image from Microsoft's devcontainers repository.
- Remove unused comments and configurations from the file.

Closes mrlt8#1354
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants