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

Clips not playing in HA browser #21

Closed
Halytskyi opened this issue Jan 25, 2021 · 11 comments
Closed

Clips not playing in HA browser #21

Halytskyi opened this issue Jan 25, 2021 · 11 comments

Comments

@Halytskyi
Copy link

Version of the custom_component

1.0.1 (also tried on 1.0.0)

Configuration

Nothing specific, just copied "custom_components/frigate" to my "custom_components" folder in HomeAssistant and configured it (via HA integrations) to frigate host.

Describe the bug

I see clips in (and images/thumbnails) but when I click on it - it not playing. In debug console I see 404:
ha_frigate
Via Frigate UI everything works.

Tried on versions:
Frigate: 0.8.0-beta2-amd64, 0.8.0-rc[2-5]-amd64
Home Assistant: “2020.12.2” and “2021.1.[1-5]” versions.

Maybe required more configuration here. In documentation https://www.home-assistant.io/integrations/media_source/#playing-media-from-a-media-source "media_content_id" should be like "media-source://media_source/<media_dir>/", where "media_source" - not clear for me, it should be local dir (but seems not, as local dirs configured in "media_dirs") or it's remote address? In debug logs (below) you can see that "media_content_id" defined as "media-source:/ frigate/clips/outdoor_front-1611527640.595162-h066r2.mp4", where 2 questions:

  1. Why I see space after "media-source:/ "? Is this "bug" in HA logs?
  2. "media_source" here "frigate" - is it should not be ip[:port]/dns address to frigate?

P.S. About my configuration. Frigate running in container on Kubernetes. HA running on LXD. No any issues in communication between HA and frigate, also everything works except one this issue.

Debug log

Jan 24 19:11:35 ha hass[126316]: 2021-01-24 19:11:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140664542335280] Received {'type': 'media_source/resolve_media', 'media_content_id': 'media-source:/ frigate/clips/outdoor_front-1611527640.595162-h066r2.mp4', 'id': 29}
Jan 24 19:11:35 ha hass[126316]: 2021-01-24 19:11:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140664542335280] Sending {'id': 29, 'type': 'result', 'success': True, 'result': {'url': '/api/frigate/clips/outdoor_front-1611527640.595162-h066r2.mp4?authSig=<hidden>', 'mime_type': 'video/mp4'}}
Jan 24 19:11:35 ha hass[126316]: 2021-01-24 19:11:35 DEBUG (MainThread) [homeassistant.components.http.auth] Authenticated ha_ip_addr for /api/frigate/clips/outdoor_front-1611527640.595162-h066r2.mp4 using signed request
Jan 24 19:11:35 ha hass[126316]: 2021-01-24 19:11:35 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/frigate/clips/outdoor_front-1611527640.595162-h066r2.mp4 to ha_ip_addr (auth: True)
Jan 24 19:11:36 ha hass[126316]: 2021-01-24 19:11:36 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.028 seconds
@blakeblackshear
Copy link
Owner

What happens if you right click and open that url in a new chrome tab? What does the 404 page look like?

@Halytskyi
Copy link
Author

It's not possible to open in new tab from HA media browser:
ha_frigate2
But if try open url which in request:

https://my_ha_hostname/api/frigate/clips/outdoor_front-1611527640.595162-h066r2.mp4?authSig=<hidden>

I getting "401: Unauthorized" as seems token expired (or it's one time token - didn't check in docs how it works).

@blakeblackshear
Copy link
Owner

If you try to use the url immediately after it fails from homeassistant, the authSig will still be valid. You can click the file again to have homeassistant generate a new one.

@Halytskyi
Copy link
Author

Halytskyi commented Jan 26, 2021

White page with 404:
ha_frigate3

@blakeblackshear
Copy link
Owner

Any chance that url is being captured upstream by traefik or nginx? That 404 is not coming from frigate and the headers indicate it is served up by nginx.

@Halytskyi
Copy link
Author

Halytskyi commented Jan 27, 2021

Ok, yes, it was Nginx as frontend for HA and Traefik as frontend for Frigate. To remove this relations I configured and send direct requests (without Nginx and Traefik) and have exactly the same results. Now you can see in headers "Python" as I made request directly to HA (communication with Frigate now through k8s service - without any ingress controllers):

ha_frigate4
Also I tried only direct url - the same white page with 404 error.

As I already mentioned, for me it's very strange that in HA debug log I see space after "media-source:/ " instead of 2nd slash. Maybe this is can be related?

'media-source:/ frigate/clips/outdoor_front-1611527640.595162-h066r2.mp4'

@blakeblackshear
Copy link
Owner

That isn't related. The URL looks correct. Can you check the logs inside frigates container at /var/log/nginx/*.log? I am guessing the request is being stopped before making it to frigate. Do you have any errors in homeassistant on startup?

@Halytskyi
Copy link
Author

Yes, in Nginx logs when I go to HA web browser I see:

10.172.0.2 - - [27/Jan/2021:18:06:36 +0000] "GET /api/events/summary?has_clip=1 HTTP/1.1" 200 851 "-" "HomeAssistant/2021.1.5 aiohttp/3.7.3 Python/3.8" "192.168.199.199"
10.172.0.2 - - [27/Jan/2021:18:06:36 +0000] "GET /api/events?limit=50&has_clip=1 HTTP/1.1" 200 944493 "-" "HomeAssistant/2021.1.5 aiohttp/3.7.3 Python/3.8" "192.168.199.199"
10.175.0.0 - - [27/Jan/2021:18:06:37 +0000] "GET /api/stats HTTP/1.1" 200 271 "-" "HomeAssistant/2021.1.5 aiohttp/3.7.3 Python/3.8" "-"

But when I click on clip to watch it - no any requests to Nginx (Frigate) side.

No any errors in HA log, just warning:

Jan 27 10:13:53 ha hass[150809]: 2021-01-27 10:13:53 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for frigate which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant.

which definitely should not be related.

Ok, I'l try debug more from HA side when will have little bit more free time...

@blakeblackshear
Copy link
Owner

The screenshot of the 404 page you posted looks like the one Traefik uses

@Halytskyi
Copy link
Author

It's strange, but after I click "reload" button for Frigate integration - it started work even through Traefik

@Halytskyi Halytskyi reopened this Jan 31, 2021
@Halytskyi
Copy link
Author

Oh no, @blakeblackshear you was right, this is Traefik, after changing url (in Frigate integration) to direct service and checking by tcpdump I saw that traffic continue going to Traefik and it only fixed (changed to direct service) after HA restart.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants