kushagharahi / homebridge-dahua-alerts

Routes motion alerts for Dahua and Lorex camera streams to homebridge-camera-ffmpeg
27 stars 13 forks source link

Remove timeout and rely on keepalive #27

Closed magic7s closed 2 years ago

magic7s commented 2 years ago

Could you give this a look? I tested it a bit on my camera and its working. I'm going to do more extensive testing this week. Network traces look good.

kushagharahi commented 2 years ago

Does it reconnect successfully?

I think the problem with this is that there's no way to know if a socket connection has closed since the cameras don't properly close the connection. The first connection will last 12-24 hours and after that... silence. No RST or FIN sent by the camera to close the connection so the plugin assumes the socket is still alive. Hence, the timeout workaround, don't get any info from the camera for $TIMEOUT, tear down the connection and create a new one.

kushagharahi commented 2 years ago

This is the same change as https://github.com/kushagharahi/homebridge-dahua-alerts/issues/21#issuecomment-912924712

7ab02ac

We determined that it wasn't successful

magic7s commented 2 years ago

Yes it does. I was able to reboot the camera and it reconnected. Also I unplugged the camera for about 15 minutes, when I plugged it back it, it reconnected.

On Sep 21, 2021, at 6:13 PM, Kusha Gharahi @.***> wrote:

 Does it reconnect successfully?

I think the problem with this is that there's no way to know if a socket connection has closed since the cameras don't properly close the connection. The first connection will last 12-24 hours and after that... silence. No RST or FIN sent by the camera to close the connection so the plugin assumes the socket is still alive. Hence, the timeout workaround, don't get any info from the camera for $TIMEOUT, tear down the connection and create a new one.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

kushagharahi commented 2 years ago

Ok -- I'll check it out! Sounds interesting

kushagharahi commented 2 years ago

Wow you're totally right!!!!!! It does detect and reconnect when you turn the camera off. I would like to test this overnight for the socket closing out, if it reconnects we can merge this upstream tomorrow evening!

Well done 👏 👏 👏 👏 👏 👏

kushagharahi commented 2 years ago

So the problem with https://github.com/kushagharahi/homebridge-dahua-alerts/commit/7ab02ac305a63d3f83b556239aa7c9bb1e857f93 was reconnecting on close, rather than end... damn nice work