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

Nest camera stops working after 5 minutes #723

Closed
Inrego opened this issue Oct 31, 2023 · 19 comments
Closed

Nest camera stops working after 5 minutes #723

Inrego opened this issue Oct 31, 2023 · 19 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@Inrego
Copy link
Contributor

Inrego commented Oct 31, 2023

After 5 minutes, the nest stream stops working. I've set it up manually with the parameters (not through HA).
So something about the reconnection seems to not be working correctly.

Nothing seems to be logged around the time when the stream stops working, so I'm not sure what else I can provide.

@heroash88
Copy link

I think this is a limit Google enforced in their API unless you stream it on the Google Home App.

@Inrego
Copy link
Contributor Author

Inrego commented Nov 7, 2023

Yes, there's a 5 minute limit, as per the documentation. But there's also an api call to extend the stream (I think this is what the Google Home App and Nest Hubs does):
image

From the go2rtc documentation, it sounds like it should also do it:
image

Stream reconnects every 5 minutes

It's not clear whether it uses the extend api, or if it's just supposed to reconnect when the stream ends after 5 minutes. But neither is happening. The camera just stops working after 5 minutes.

@Inrego
Copy link
Contributor Author

Inrego commented Nov 7, 2023

Another fun thing I experienced recently, was that when the stream stops working, then Frigate suddenly used all remaining 20 GB RAM on my machine within seconds, rendering the machine unresponsive due to lack of RAM.

@AlexxIT AlexxIT added the question Further information is requested label Nov 7, 2023
@AlexxIT
Copy link
Owner

AlexxIT commented Nov 7, 2023

go2rtc not using extend API. There are no such plans in the near future.
The fact that the stream is not reconnecting is a bug. It shouldn't be.

@Inrego
Copy link
Contributor Author

Inrego commented Nov 7, 2023

I'm sorry, but I'm having a hard time understanding what you mean by your second line

The fact that the stream is not reconnecting is a bug. It shouldn't be.

Should it be reconnecting automatically, or not?

@AlexxIT
Copy link
Owner

AlexxIT commented Nov 7, 2023

It should be reconnecting. But I haven't this source for testing.

@tomg1970
Copy link

Hello how exactly do I get the 'device_id=' and the 'refresh_token' ?

@Inrego
Copy link
Contributor Author

Inrego commented Nov 22, 2023

Hello how exactly do I get the 'device_id=' and the 'refresh_token' ?

It's kind of off topic, but you can use this site:
https://device-access-sample.web.app/

@Inrego
Copy link
Contributor Author

Inrego commented Nov 22, 2023

It should be reconnecting. But I haven't this source for testing.

I might have a go at making a PR for it at some point when I have the time.
Would you accept if I implement calling the stream extension api, rather than reconnecting (while still having reconnect as a fallback if connection is lost)?

@AlexxIT
Copy link
Owner

AlexxIT commented Nov 22, 2023

If the code will be correct and logical - I will accept it :)

@Inrego
Copy link
Contributor Author

Inrego commented Nov 22, 2023

I'll do my best. I've no experience in Go, but I've many years of professional experience in C#

@Inrego
Copy link
Contributor Author

Inrego commented Dec 21, 2023

I'm afraid I won't have the time to get the proper understanding of the workings, to fix the issue. But I'll share my sparse findings here:
When the stream expires, the webrtc state changes to disconnected, and then closed.

When I manually close the stream by closing VLC, then the disconnected even is absent, and it only closes.

I believe the first step should be to fix the issue of reconnection. Because even if the extend stream is implemented, there could be edge cases where it's not fired in time, or for other reasons fail.

@Inrego
Copy link
Contributor Author

Inrego commented Dec 30, 2023

After the stream expires, frigate shows the stream as full of flickering artifacts, and it uses up all my RAM (~30 GB) in seconds.

If I change this small thing, it successfully reconnects without issue:
File: pkg\webrtc\conn.go
Function: pc.OnConnectionStateChange

Change from: case webrtc.PeerConnectionStateDisconnected, webrtc.PeerConnectionStateFailed, webrtc.PeerConnectionStateClosed:
Change to: case webrtc.PeerConnectionStateFailed, webrtc.PeerConnectionStateClosed:

So basically no longer closing the connection on Disconnect.

However, I'm hesitant to make such a change in webrtc module since it could cause unintented consequences in other areas than Nest.

But maybe you can use this information to implement a proper fix, @AlexxIT ?

@AlexxIT
Copy link
Owner

AlexxIT commented Dec 30, 2023

Just removing PeerConnectionStateDisconnected is very strange. Maybe problem with double Close call. Maybe there is some block there. You need to investigate problem more deeper.

@Inrego
Copy link
Contributor Author

Inrego commented Dec 30, 2023

Investigating is a bit hard, because whenever it happens my server more or less crash due to frigate consuming all the ram.

@AlexxIT
Copy link
Owner

AlexxIT commented Dec 31, 2023

So this is a very rare problem?

@Inrego
Copy link
Contributor Author

Inrego commented Dec 31, 2023

No it's very reproducible. The stream expires after the 5 minute mark, and then everything goes south

@AlexxIT AlexxIT self-assigned this Apr 23, 2024
@AlexxIT AlexxIT added bug Something isn't working and removed question Further information is requested labels Apr 23, 2024
@AlexxIT
Copy link
Owner

AlexxIT commented Apr 23, 2024

Should be fixed #855

@AlexxIT AlexxIT added this to the v1.9.0 milestone Apr 30, 2024
@AlexxIT
Copy link
Owner

AlexxIT commented Apr 30, 2024

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

4 participants