fwestenberg / reolink_dev

Home Assistant Reolink addon
MIT License
550 stars 101 forks source link

Home Assistant error: "Host 192.168.110.xxx error renewing the Reolink subscription" #550

Open rainbowbreeze opened 2 years ago

rainbowbreeze commented 2 years ago

Describe the bug I've 4 Reolink RLC-811A connected directly to my LAN (no NVR). 192.168.110.121, .122, .124, .125 All the four cameras have the same firmware version, and configurations I've configured all of them under HA using the reolink_dev custom integration

For two of them the following error continues to pop up in HA logs

Host 192.168.110.124 error renewing the Reolink subscription
Host 192.168.110.122 error renewing the Reolink subscription

I removed the cameras, and re-added them, and I get the same error. Interestingly enough, .121 and .125 don't show the error.

Environment: Please provide useful information about your environment, like:

Additional context Here the debug logs from HA with the error happens (username and pwd obscured):

2022-08-15 15:55:24.109 DEBUG (MainThread) [reolink.subscription_manager] Host 192.168.110.124: Connection error Cannot connect to host 192.168.110.124:8000 ssl:default [Connect call failed ('192.168.110.124', 8000)]
2022-08-15 15:55:24.109 ERROR (MainThread) [custom_components.reolink_dev.base] Host 192.168.110.124 error renewing the Reolink subscription
2022-08-15 15:55:24.113 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.110.124 (Subscription) request data:
<soap:Envelope xmlns:add="http://www.w3.org/2005/08/addressing" xmlns:b="http://docs.oasis-open.org/wsn/b-2" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header><wsse:Security soap:mustUnderstand="true" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-3839ddc1-4bf7-4ae8-a24d-4fc09e707dd6">
<wsse:Username>XXXXXXXXX</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">XXXXXXXXX</wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">X21BCn+NQzufUwa4LPr+wQ==</wsse:Nonce>
<wsu:Created>2022-08-15T13:55:24.000Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soap:Header>
<soap:Body>
<b:Subscribe>
<b:ConsumerReference>
<add:Address>http://192.168.100.6:8123/api/webhook/84118dfcafa7b202eaaeba6c5dc8b5b19a2b65d3ba6a5f1d1157a4e234122e91</add:Address>
</b:ConsumerReference>
<b:InitialTerminationTime>PT15M</b:InitialTerminationTime>
</b:Subscribe>
</soap:Body>
</soap:Envelope>
2022-08-15 15:55:24.119 DEBUG (MainThread) [reolink.subscription_manager] Host 192.168.110.122: Connection error Cannot connect to host 192.168.110.122:8000 ssl:default [Connect call failed ('192.168.110.122', 8000)]
2022-08-15 15:55:24.120 ERROR (MainThread) [custom_components.reolink_dev.base] Host 192.168.110.122 error renewing the Reolink subscription
2022-08-15 15:55:24.125 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.110.122 (Subscription) request data:
<soap:Envelope xmlns:add="http://www.w3.org/2005/08/addressing" xmlns:b="http://docs.oasis-open.org/wsn/b-2" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header><wsse:Security soap:mustUnderstand="true" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-c7d3f96f-9919-44b3-9a9c-a026fe7f6a0f">
<wsse:Username>XXXXXXXXX</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">XXXXXXXXX</wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">/Jiu5g5UQCCNabTVLzTKwg==</wsse:Nonce>
<wsu:Created>2022-08-15T13:55:24.000Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soap:Header>
<soap:Body>
<b:Subscribe>
<b:ConsumerReference>
<add:Address>http://192.168.100.6:8123/api/webhook/4ac8c0a4c42b2841ff18f2cd9eb77344463a90dfc62ea073fc060174a64229e5</add:Address>
</b:ConsumerReference>
<b:InitialTerminationTime>PT15M</b:InitialTerminationTime>
</b:Subscribe>
</soap:Body>
</soap:Envelope>
2022-08-15 15:55:24.131 DEBUG (MainThread) [reolink.subscription_manager] Host 192.168.110.124: Connection error Cannot connect to host 192.168.110.124:8000 ssl:default [Connect call failed ('192.168.110.124', 8000)]
2022-08-15 15:55:24.160 DEBUG (MainThread) [reolink.subscription_manager] Host 192.168.110.122: Connection error Cannot connect to host 192.168.110.122:8000 ssl:default [Connect call failed ('192.168.110.122', 8000)]

Happy to provide additional debug info if needed.

JimStar commented 1 year ago

@pod31 Do you connect to NVR or directly to camera?

JimStar commented 1 year ago

Ah, sorry I've just seen "no NVR" in your message...

didrocks commented 1 year ago

Same here, no NVR, direct connexion to the camera and I have a lot of random errors as in this post, making the sensors switching from available to unavailable every 2 minutes. My network is an unifi network, the 2 reolink cameras (510A) and HA wired to the switch.

I’m happy to test your new patch once you polished it :)

JimStar commented 1 year ago

Yep, the previously mentioned issues already work well on my side after big rework of the code, but I still need to polish all things up before publishing this.

But in addition to these, I've found a bug in the Reolink's RLN8-410 NVR I have, which results in some notifications from some cameras getting lost (at least in the latest firmware version I have installed). But this is actual only for those (like me) who connects to NVR, not to cameras directly.
I'm still communicating with Reolink about that, let's see if they would be able/willing to fix it...

rainbowbreeze commented 1 year ago

@rainbowbreeze or any others who have several cameras with direct connection (without NVR), and who has similar "subscription" errors in the log.

Could you please check that you have ONVIF enabled in all of your cameras? So that this reason could be completely eliminated from possible causes? I'm asking because I've already found the exact cause of all these problems in the NVR case, but I want to be sure that it would work for directly connected cameras too...

Sorry for the late reply @JimStar , I'm just back from vacations. I confirm I've ONVIF enabled on all my camera, and updated to 0.56. Unfortunately, I still see the "Host 192.168.110.12x error renewing the Reolink subscription" for all my 4 cameras, but it seems it happens less often than before. I also have a lot of other errors too related to reolink_dev in the log, I don't know if they're somehow related. In order of occurrence:

JimStar commented 1 year ago

Sorry in advance for a long post, but there is a lot to explain today.;)

OK, after the promise from Reolink's "first-line" person to forward my bug description of their NVR-firmware to "senior engineers", I've finally got a response from them...
Kinda what I expected - you would expect the same lazy blah-blah from any hardware-manufacturer nowadays... it is enough for them that it "sells good enough", so why pay for additional time to engineers to fix some bugs in it?.. If they would be really interested and "worked on it" to get it fixed as they say - the bug is so trivial that it would take me just a firmware source code and a couple of hours of work to fix something like this...

Dear Jim,

Sorry for the delay.

We really appreciate your findings and feedback. Our engineers have known the issue and are already working on it.
Since it may take some time to analyze and debug, we're afraid that we're not able to offer a final solution right now.

Currently, would you mind using the push notifications or email alerts temporarily? Once we figure out the solution, we will keep you informed immediately.

If you have any other concerns, please let us know. Have a nice day!

Best Regards Reolink Support Team-Jeanine

So for now I only see a proper way to use any Home Assistant's ONVIF component (not just this one) like many here already do - connecting it directly to cameras NOT connecting it to Reolink's NVR. Because of one bug and one accompanying issue in their NVR firmware:

  1. Their NVR only sends the ONVIF motion-notification if the motion was detected by the camera connected to the very first channel.
    It was hard to me to catch this one, because some of my cameras have some common areas with the first-channel camera in their view, so when the first camera sent the motion-notification, the subsequent GetAiState request of the component (to get the exact object-type detected) received AI-motion from other cameras too... So it looked like the ONVIF notifications from these cameras work too, but it was not the case. So, with this bug, the Reolink NVR will only notify about motion-events on the very first channel (at least mine RLN8-410 does).
  2. Another issue I've noticed, thanks to @leroyloren: in the log he attached here (where he has directly connected RLC-810A camera), I can see that this camera sends really reach ONVIF notification that has all the information about what exact object was just detected by AI, so the component (if it would support it) would not need to spend additional time and resources sending additional request over the network and then receive and parse an additional response to just be able to know what exact object was detected and what sensor to trigger. If the information from that camera's ONVIF notifictaion would be used - the component would just know immediately what motion-sensor to trigger, without any additional communication with the camera/NVR.
    BUT, if the same kind of camera (RLC-822A in my case) is connected to NVR - the NVR dropps all this useful information which the camera notifies the NVR with, and sends to the ONVIF-client the notification that contains just a simple "some motion is detected" notification. So the client (Home Assistant component in this case) is forced to spend additional time and resources before being able to finally trigger an appropriate sensor (that triggers actions in turn).

I've already implemented the support of these reach notifications it in my improved version, so in the case when the ONVIF-notification would come in such reach form from newer cameras - it would work much more efficient, just using the info directly from that notification, instead of asking the ONVIF-host back and forth about "what exact object have you detected?"...
And in addition it now works properly with NVRs and their namings in Home Assistant (known issue reported somewhere in this tracker, where the name of the NVR is messed up with cameras' names). The only issue with NVRs is mentioned above - but it already depends on Reolink willing/unwilling to fix their bug finally, not on Home Assistant software...

Something like this..:) The only thing regarding all my improvements - they ended up to be so significant, that I've severely re-wrote big parts of both the reolink_dev and its reolink Python library code...
If I would make two pull-requests for them - it would definitely be not a simple "merge" anymore, @fwestenberg would need to completely inspect all the code from scratch, no merge-tool would show it as split to simple "differences" sections... Because I even prefer my own code-formatting style (I work mostly with C++ recent 10 years), so it kinda finds its reflection in my Python code too..;)
Thus I think I will just create a separate GitHub project, to not bother @fwestenberg with all this, and to not raise long discussions about particular chunks of code... Anyway I just do it for my own, just to be able to use my CCTV system with all the force it's capable of, and to be sure I'm not losing any motion-events. And if somebody else would like to use it too - I'll post here a link after it's finally done.

And I'm REALLY THANKFUL for all this big job done with this component by @fwestenberg. Thank you big time mate!

cpainchaud commented 1 year ago

Hi there!

@fwestenberg has not been active for a year at least, I am the only other admin of this repo and I do believe a complete rewrite is needed.

I think best way to go forward is to make your own project from scratch which I will gladly test and potentially contribute.

I also think that subscriptions are buggy even on standalone cameras, in my case I get them a dozen times a day, mainly due to camera crashing. I ended up doing active polling 3 seconds by changing some values in reolink_devs's config.

Electronlibre2012 commented 1 year ago

Thanks @JimStar and @cpainchaud for your great work! cant wait for a new repo! thanks again

JimStar commented 1 year ago

@cpainchaud Could you describe please, what's exactly happening with crashes/subscriptions-losses on your cameras?.. How many cameras? Does this happen on all of them?

I just don't observe neither crashes nor any of subscriptions cancels with neither my four RLC-822A cameras nor with RLN8-410 NVR they're connected to... I'm actually subscribed to NVR (not directly to cameras), at least so far, but for its first channel it always sends notifications without any losses... Which means that it by itself receives all the notifications from a camera connected to its first channel... And I've never seen any of them crashing/reloading (and I have a periodic-auto-restart disabled on the NVR).
Actually, while testing my improved version, I've completely disabled any polling, and only use ONVIF notifications. And the NVR never stops notifying, and doesn't lose any movements on its first channel... I even need to disable it when we're sleeping - otherwise the TTS-lady keeps saying "Vehicle up front" the whole night..;)

Maybe you have some hardware issues with your camera(s)? Are you sure you have enough power/voltage on them (whatever POE or direct-adapter you have connected to them)? Are you sure they're not overheating on the sun?
If it works OK on my side with same cameras, then to me it looks like most likely either not enough power (weak adapter?), not enough voltage (too long and too thin power cable?), or (I meet this one very often): chip overheating. In the case of microcontroller overheating you'd be experiencing random crashes... I had fixed some crashing devices in the past (like e.g. a digital video-player) just gluing a heatsink to their microcontroller with a thermal glue.

cpainchaud commented 1 year ago

Actually some parts of services are crashing, the camera is still available but the internal web server instance that serves API crashes and restart thus loosing all current sessions and return error 500. During these crashes, video stream and phone notifications still work.

JimStar commented 1 year ago

Weird, I didn't experience any of that...

Electronlibre2012 commented 1 year ago

Hello @JimStar

any news about your repository please?

Thanks

JimStar commented 1 year ago

I'm polishing last little things... Going to make it public in one-two days I think... I'll post here a link when it's done.

Electronlibre2012 commented 1 year ago

thanks!

Le mer. 28 sept. 2022, 22:06, Jim Star @.***> a écrit :

I'm polishing last little things... Going to make it public in one-two days I think... I'll post here a link when it's done.

— Reply to this email directly, view it on GitHub https://github.com/fwestenberg/reolink_dev/issues/550#issuecomment-1261287808, or unsubscribe https://github.com/notifications/unsubscribe-auth/AL4SIWKXXINTLHHSSWS7Q33WASCLPANCNFSM56SPMLMA . You are receiving this because you commented.Message ID: @.***>

Electronlibre2012 commented 1 year ago

Hello,

just a little feedback for my problem with grey period (or black period depending of the ANDROID/WEB/PC software Reolink),

after 27 mail with Reolink Support in Germany, they have send a new NVR to me, and the good news is it works like a charm! no more no recordings period in the timeline.

And one more good thing is this is the new board hardware N3MB01 instead of the one i bought (N2MB02), dont know if my problem was related or not with the board number...but the problem is solved!

happy day all!

JimStar commented 1 year ago

OK, I've finished it in the first draft.

Works OK for me.
But I use it connected to my NVR, not to each camera separately. So if you'll get any bugs - feel free to report them in the reolink_cctv repository tracker.

The change-log list is too big, so I'm not mentioning any of the changes here: just read all the notes in the repo's README on its main page.

https://github.com/JimStar/reolink_cctv

Electronlibre2012 commented 1 year ago

Hello @JimStar

awesome work! thanks a lot

i try for a few minutes now and i have post a issue on your Github repo,

it works great only one error message

https://github.com/JimStar/reolink_cctv/issues/2

JimStar commented 1 year ago

@Electronlibre2012 I'll be watching for the log record you've reported... Never got it on my side though, maybe just your NVR did not respond for some time right after HA restarted...
Let's continue all the discussions about that already in my repo's tickets/discussions, to not flood this ticket with offtopic...

moseisleydk commented 1 year ago

Shoutout to @fwestenberg and for sure to @JimStar, I really appriciate the Reolink updates !!

@JimStar - Dont have some "Buy Me a Beer" stuff?

JimStar commented 1 year ago

@JimStar - Dont have some "Buy Me a Beer" stuff?

Nope.;)