You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I am using your nice project as part of a larger home-made alarm system and noticed that after some time (can be multiple weeks), the event stream simply stops. I assume that is because the websocket stream is somehow interrupted and not re-established.
My question:
Is there anything I can do in any of the events thrown by unifi-protect to (1) detect this has happened and (2) reconnect?
Note:
I found this code in your homebridge project:
// Bootstrap refresh loop.
const bootstrapRefresh = (): void => {
// Sleep until it's time to bootstrap again.
setTimeout(() => void this.bootstrapNvr(), PROTECT_CONTROLLER_REFRESH_INTERVAL * 1000);
};
// Let's set a listener to wait for bootstrap events to occur so we can keep ourselves in sync with the Protect controller.
this.ufpApi.on("bootstrap", () => {
// Sync our device view.
syncUfpHomeKit();
// Refresh our bootstrap.
bootstrapRefresh();
});
// Kickoff our first round of bootstrap refreshes to ensure we stay in sync.
bootstrapRefresh();
Is that the solution? Keep calling the bootstrap call every x seconds?
To Reproduce:
Register an unifi-protect.on("message") listener
Do a unifi-protect.login()
Do unifi-protect.getBootstrap()
Wait for the on("message") to stop being triggered
Logs:
The unifi-protect logs remain empty (no errors or anything are thrown)
Screenshots:
The text was updated successfully, but these errors were encountered:
After reading all the code in https://github.com/hjdhjd/unifi-protect/blob/main/src/protect-api.ts, I now understand that indeed calling the bootstrap() method will reestablish the ws connection.
I will add similar code to my project to ensure the ws stream gets re-established every "x" seconds.
Closing my own ticket.
This issue is locked to prevent necroposting on closed issues. Please create a new issue for related support requests, bug reports, or feature suggestions.
Describe The Problem:
Hello, I am using your nice project as part of a larger home-made alarm system and noticed that after some time (can be multiple weeks), the event stream simply stops. I assume that is because the websocket stream is somehow interrupted and not re-established.
My question:
Is there anything I can do in any of the events thrown by unifi-protect to (1) detect this has happened and (2) reconnect?
Note:
I found this code in your homebridge project:
Is that the solution? Keep calling the bootstrap call every x seconds?
To Reproduce:
Register an unifi-protect.on("message") listener
Do a unifi-protect.login()
Do unifi-protect.getBootstrap()
Wait for the on("message") to stop being triggered
Logs:
Screenshots:
The text was updated successfully, but these errors were encountered: