Skip to content
New issue

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

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

Already on GitHub? # to your account

If host is rebooted, first connection fails #7

Open
chkpwd opened this issue Jan 12, 2025 · 0 comments
Open

If host is rebooted, first connection fails #7

chkpwd opened this issue Jan 12, 2025 · 0 comments

Comments

@chkpwd
Copy link

chkpwd commented Jan 12, 2025

If the host is rebooted, when the container comes up and attempts to initialize a connection with Unifi Protect, a traceback is triggered:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/viewport/bin/../src/viewport/src/main.py", line 77, in main
    urls=args['<url>']).run()
                        ^^^^^
  File "/opt/viewport/bin/../src/viewport/src/cli/commands.py", line 56, in run
    livestreams = protocol_controllers[url.scheme].new_livestream(url)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/viewport/bin/../src/viewport/src/backend/protocols/unifi.py", line 86, in new_livestream
    self._apis[key].login()
  File "/opt/viewport/bin/../src/viewport/src/backend/protocols/unifi.py", line 144, in login
    r = requests.get(url_prefix, verify=False)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/requests/adapters.py", line 700, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='192.168.1.253', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f4cbebccd40>: Failed to establish a new connection: [Errno 113] Host is unreachable'))
Critical error, stopping. Exit code: 127

I'm sure the reboot is a symptom of a bigger issue, I'm just not sure where or why?

docker-compose.yml -

name: camera-viewer
services:
  viewport:
    image: j4zzcat/viewport:1.4.0
    command: [ 'streams', 'unifi://user:pass@ip-addr/g3b-front-left,g3b-front-right,g3b-parking-left,g3b-parking-right,g3b-side-left,g3b-side-right,g3b-back-right,g3b-back-left,g3b-back-generator' ]
    network_mode: host
    volumes:
      - type: tmpfs
        target: /ramfs
        tmpfs:
          mode: 1777
    restart: always
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8001/html/"]
      interval: 2s
      timeout: 5s
      retries: 3
      start_period: 10s

To mitigate this, I've added a container restart to my .xinitrc:

#!/usr/bin/env bash

openbox &

check_page() {
  curl -s http://localhost:8001/html/ | grep -q "html"
}

docker restart camera-viewer-viewport-1

until check_page; do
  sleep 2
done

firefox --kiosk http://localhost:8001/html/
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant