-
Notifications
You must be signed in to change notification settings - Fork 52
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
XML parse errors #40
Comments
Are you comfortable editing the pyhik package files to add some more debugging info? In the hikvision.py file i'd like you to change line 497 from:
to this:
That will output the actual parse error which should help track down the problem. |
OK. Done. This is the new output, getting no element found ... |
Ok, not as helpful as i'd hoped. Can you add a new logging line under that one? This should log the collected XML so I can see what is getting collected incorrectly.
|
Lot's of data now:
|
Ok, I see the issue, the question is why is it happening and is it something we can fix. For whatever reason messages are getting jumbled together and closing tags aren't being inserted properly. If you look at the snippet below from you log you can see a rogue Best way to troubleshoot further is to run a curl on your event stream and see if the XML is actually being transmitted through that way or if pyhik is processing it incorrectly.
Log snippet:
|
Can it be that one alarm message is interrupted by another? I have different motion alarms configured and it can happen that multiple of those are triggered almost simultanously. Executing the curl command returns this: <title>Document Error: Unauthorized</title>Access Error: 401 -- UnauthorizedAuthentication Error I'm sure though that USER:PASS is correct. |
I'm guessing you have digest rather than basic authentication enabled in the camera. Give this syntax a try:
|
That works. |
That didn't properly work. Using file. |
Let that run for a little while, 5-10minutes, then post the log again. In that snippet everything looks OK. |
Ok, that log shows the same jumbling of messages so the feed is coming that way from the camera. That being said there isn't much the library can do beyond what it's already doing, discard the bad data and keep on processing. It seems like most of the overlap cases are a linedetection event interrupting a motion event. Maybe try playing with your camera settings to mitigate that happening? |
How does pyHik handle this case currently? Are both events discarded? An alternative could be that pyHik restarts event processing when the interrupting event arrives and discards the interrupted event; |
At the moment both events are discarded since the event string is only cleared after an ending event is found. A simple fix would be to clear the event string when a start event is found. You can test this by adding the below after line 485: Line 485 in dfc0cee
If it works for you i'll implement the edit and increase the version. |
In the meantime I observed the following: I had expert mode turned on for motion detection and defined multiple (4) areas with different sensitivity. That leads to a pretty long data stream when it triggers which is sometimes interrupted by another event as we know. When turning expert mode off, the data stream for that event is much shorter. I've tested with expert mode off for a while and did not see any jumbled messages any more and therefore no XML parse errors either. So that could be the solution for those who do not need expert mode. |
Clarifying question: you mean changing the 2 lines starting at #485:
to the following 3 lines?
|
I don't think this has to do with events interrupting each other, you will notice it only occurs on the really long event messages, looks like there is a cutoff where any lines which don't fit within the message limit (probably 2048 characters) just get dropped. It looks like enough data is there you could attempt to parse the unfinished event data but it's far from ideal, the best way would be figuring how to reduce the RegionCoordinates tags from the camera, if that is even possible? |
I added a change to the recently release 0.2.4 version that will at least catch the last event when they get jumbled together. I'll leave this issue open for now since that's only a partial fix. |
I have a Hikvision DS-2CD2045FWD-I cam with firmware V5.6.0 build 190507. I'm getting XML parse errors. The cam is hardwired using a powerline connection. The connection is pretty stable providing ~ 75Mbit/s. I'm also using Hikvision's iVMS-4500 app on my Android smartphone. That way I can compare results. During testing I'm receiving all motion triggers on the phone and also pyHik receives them but generates lots of XML parse errors.
The text was updated successfully, but these errors were encountered: