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

Error parsing body: Error: Non-whitespace before first tag. Line: 0 Column: 1 Char: - #5

Closed
BlackandGold1 opened this issue Dec 10, 2022 · 12 comments · Fixed by #6
Closed
Assignees

Comments

@BlackandGold1
Copy link

BlackandGold1 commented Dec 10, 2022

Hallo,

leider macht der Adapter bei mir nichts. Habe die aktuelle Version 0.0.5.
In den Objekten sind beide Kameras zu sehen anhand ihrer Mac und stehen immer auf false.
Im log habe ich folgendes stehen:
hikvision-alarmserver.0 | 2022-12-10 14:58:42.750 | error | Error parsing body: Error: Non-whitespace before first tag. Line: 0 Column: 1 Char: -

Die Einstellungen in den Cams sind gemacht und laut Test erreichbar.

leider weiß ich nicht weiter und hoffe auf Hilfe.

Screenshot 2022-12-10 153017

Screenshot 2022-12-10 153119

Screenshot 2022-12-10 153158
Screenshot 2022-12-10 153439

@raintonr
Copy link
Collaborator

I see from your screenshot that you have been using a previous version as the device IDs still contain colons. I removed colons from the IDs to be more consistent in 0.0.5. For this reason you should remove the existing devices and they will be re-created when events are recieved.

I don't see why if parsing was working before that it isn't now though. I didn't change anything around that.

Please turn debug on for the adapter and post the XML received here so I can see exactly what the camera is sending. Looks like we will need to trim whitespace before parsing or something.

@raintonr
Copy link
Collaborator

I see... whatever camera that is (what model is this?) it is sending the XML in part of a multipart message.

Can you please copy/paste the data here properly (not in an image) so I can use as test data?

@BlackandGold1
Copy link
Author

Sorry but I don't know how to get this file.

Model: DS-2DE2A404IW-DE3 and DS-2DE3A404IW-DE/W

@raintonr
Copy link
Collaborator

Sorry but I don't know how to get this file.

In the browser you are looking at, instead of taking the screenshot, just select the message, copy, then paste here.

Alternatively, there is a 'DOWNLOAD LOG' button at the top of the ioBroker log screen. If you download that you can attach it here. However, those log files can be large and contain sensitive information so be careful.

@raintonr
Copy link
Collaborator

No. It's stripping lots of XML. Download the log locally, open it in your favourite text editor, find the payload and try copy that.

@raintonr
Copy link
Collaborator

Sample payloads from @BlackandGold1:

--boundary Content-Disposition: form-data; name="AudioException.xml"; filename="AudioException.xml" Content-Type: application/xml Content-Length: 686 
<?xml version="1.0" encoding="UTF-8"?>
<EventNotificationAlert version="2.0"
	xmlns="http://www.hikvision.com/ver20/XMLSchema">
	<ipAddress>10.11.12.101</ipAddress>
	<portNo>8089</portNo>
	<protocol>HTTP</protocol>
	<macAddress>44:a6:42:a6:40:0d</macAddress>
	<channelID>1</channelID>
	<dateTime>2022-12-11T17:58:28+01:00</dateTime>
	<activePostCount>1</activePostCount>
	<eventType>audioexception</eventType>
	<eventState>active</eventState>
	<eventDescription>audioexception alarm</eventDescription>
	<channelName>IPdome</channelName>
	<AudioExceptionDetection>
		<alarmType>increase</alarmType>
		<audioDecibel>51</audioDecibel>
	</AudioExceptionDetection>
</EventNotificationAlert>
--boundary--
--boundary Content-Disposition: form-data; name="MoveDetection.xml"; filename="MoveDetection.xml" Content-Type: application/xml Content-Length: 2266 
<?xml version="1.0" encoding="UTF-8"?>
<EventNotificationAlert version="2.0"
	xmlns="http://www.hikvision.com/ver20/XMLSchema">
	<ipAddress>10.11.12.101</ipAddress>
	<portNo>8089</portNo>
	<protocol>HTTP</protocol>
	<macAddress>44:a6:42:a6:40:0d</macAddress>
	<channelID>1</channelID>
	<dateTime>2022-12-11T17:58:28+01:00</dateTime>
	<activePostCount>1</activePostCount>
	<eventType>VMD</eventType>
	<eventState>active</eventState>
	<eventDescription>Motion alarm</eventDescription>
	<DetectionRegionList>
		<DetectionRegionEntry>
			<regionID>3</regionID>
			<sensitivityLevel>50</sensitivityLevel>
			<RegionCoordinatesList>
				<RegionCoordinates>
					<positionX>383</positionX>
					<positionY>0</positionY>
				</RegionCoordinates>
				<RegionCoordinates>
					<positionX>638</positionX>
					<positionY>0</positionY>
				</RegionCoordinates>
				<RegionCoordinates>
					<positionX>638</positionX>
					<positionY>284</positionY>
				</RegionCoordinates>
				<RegionCoordinates>
					<positionX>383</positionX>
					<positionY>284</positionY>
				</RegionCoordinates>
			</RegionCoordinatesList>
		</DetectionRegionEntry>
		<DetectionRegionEntry>
			<regionID>5</regionID>
			<sensitivityLevel>50</sensitivityLevel>
			<RegionCoordinatesList>
				<RegionCoordinates>
					<positionX>7</positionX>
					<positionY>178</positionY>
				</RegionCoordinates>
				<RegionCoordinates>
					<positionX>244</positionX>
					<positionY>178</positionY>
				</RegionCoordinates>
				<RegionCoordinates>
					<positionX>244</positionX>
					<positionY>517</positionY>
				</RegionCoordinates>
				<RegionCoordinates>
					<positionX>7</positionX>
					<positionY>517</positionY>
				</RegionCoordinates>
			</RegionCoordinatesList>
		</DetectionRegionEntry>
		<DetectionRegionEntry>
			<regionID>6</regionID>
			<sensitivityLevel>50</sensitivityLevel>
			<RegionCoordinatesList>
				<RegionCoordinates>
					<positionX>39</positionX>
					<positionY>401</positionY>
				</RegionCoordinates>
				<RegionCoordinates>
					<positionX>216</positionX>
					<positionY>401</positionY>
				</RegionCoordinates>
				<RegionCoordinates>
					<positionX>216</positionX>
					<positionY>691</positionY>
				</RegionCoordinates>
				<RegionCoordinates>
					<positionX>39</positionX>
					<positionY>691</positionY>
				</RegionCoordinates>
			</RegionCoordinatesList>
		</DetectionRegionEntry>
	</DetectionRegionList>
	<channelName>IPdome</channelName>
</EventNotificationAlert>
--boundary--

@BlackandGold1
Copy link
Author

Sorry I don't understand

@raintonr
Copy link
Collaborator

I extracted the payloads from the files you attached then deleted for your privacy. I will now work on a fix and report back.

raintonr added a commit that referenced this issue Dec 11, 2022
@raintonr
Copy link
Collaborator

@BlackandGold1 ... I have added some logging as need to know what headers your cameras are sending. Could you please install the dev branch, run with debug, and send me the log file produced (email address on profile).

To install the dev branch, go to your ioBroker install (generally cd /opt/iobroker) and:

npm i https://github.com/raintonr/ioBroker.hikvision-alarmserver#5-error-parsing-body-error-non-whitespace-before-first-tag-line-0-column-1-char

@raintonr
Copy link
Collaborator

In your IoB web UI, got to adapters page and turn on expert mode:

image

Select install from custom URL:

image

Custom URL:

image

And paste in this:

https://github.com/raintonr/ioBroker.hikvision-alarmserver/tree/5-error-parsing-body-error-non-whitespace-before-first-tag-line-0-column-1-char

@BlackandGold1
Copy link
Author

God I am stupid. Yes I installed it and he successfully made an update.

hikvision-alarmserver.0 2022-12-11 23:05:35.262 info Server starting to listen on port 8089
hikvision-alarmserver.0 2022-12-11 23:05:35.230 info starting. Version 0.0.5 (non-npm: #5-error-parsing-body-error-non-whitespace-before-first-tag-line-0-column-1-char) in /opt/iobroker/node_modules/iobroker.hikvision-alarmserver, node: v16.18.1, js-controller: 4.0.23
hikvision-alarmserver.0 2022-12-11 23:05:34.794 debug States connected to redis: 127.0.0.1:9000
hikvision-alarmserver.0 2022-12-11 23:05:34.733 debug States create User PubSub Client
hikvision-alarmserver.0 2022-12-11 23:05:34.731 debug States create System PubSub Client
hikvision-alarmserver.0 2022-12-11 23:05:34.697 debug Redis States: Use Redis connection: 127.0.0.1:9000
hikvision-alarmserver.0 2022-12-11 23:05:34.625 debug Objects connected to redis: 127.0.0.1:9001
hikvision-alarmserver.0 2022-12-11 23:05:34.617 debug Objects client initialize lua scripts
hikvision-alarmserver.0 2022-12-11 23:05:34.496 debug Objects create User PubSub Client
hikvision-alarmserver.0 2022-12-11 23:05:34.495 debug Objects create System PubSub Client
hikvision-alarmserver.0 2022-12-11 23:05:34.493 debug Objects client ready ... initialize now
hikvision-alarmserver.0 2022-12-11 23:05:34.427 debug Redis Objects: Use Redis connection: 127.0.0.1:9001
hikvision-alarmserver.0 2022-12-11 23:05:30.010 info Terminated (ADAPTER_REQUESTED_TERMINATION): Without reason
hikvision-alarmserver.0 2022-12-11 23:05:30.009 info terminating
hikvision-alarmserver.0 2022-12-11 23:05:30.008 info Closed server
hikvision-alarmserver.0 2022-12-11 23:05:30.006 info Got terminate signal TERMINATE_YOURSELF

@BlackandGold1
Copy link
Author

BlackandGold1 commented Dec 11, 2022

OK. Triggered the cameras and sent the log file via email. There is no longer an entry in the objects. Where the Mac addresses were before everything is gone now.
Screenshot 2022-12-11 233525

raintonr added a commit that referenced this issue Dec 12, 2022
raintonr added a commit that referenced this issue Dec 12, 2022
raintonr added a commit that referenced this issue Dec 12, 2022
raintonr added a commit that referenced this issue Dec 13, 2022
raintonr added a commit that referenced this issue Dec 13, 2022
raintonr added a commit that referenced this issue Dec 13, 2022
raintonr added a commit that referenced this issue Dec 13, 2022
Handle multipart message payload ([#5](#5)).
Handle payloads without XML declaration ([#7](#7).)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants