I know how to solve this using requests, but I want to see if plugins behave better if they avoid using additional modules like that.
So far I can connect to the camera and receive messages from it. However, the datastream includes boundary's and I suspect these are not (correctly) handled by the connection. If I select XML as the connection protocol the connection terminates upon receiving the first data (see below).
self.alertstream = DomoticzEx.Connection(Name="HikCamConn", Transport="TCP/IP", Protocol="XML", Address="192.168.19.205", Port="80")
Code: Select all
2024-02-11 14:46:45.244 Queued asynchronous read aborted (192.168.19.205:80), [2] End of file.
2024-02-11 14:46:45.294 Hik: Disconnect event received for '192.168.19.205:80'.
If I select HTTP as the connection protocol it throws an error, but at least shows the content of the data received.
self.alertstream = DomoticzEx.Connection(Name="HikCamConn", Transport="TCP/IP", Protocol="HTTP", Address="192.168.19.205", Port="80")
Code: Select all
2024-02-11 14:45:03.138 Hik: onMessage called for connection: 'HikCamConn'
2024-02-11 14:45:03.138 Hik: onMessage data: {'Verb': '--boundary', 'URL': '', 'Headers': {'Content-Type': 'application/xml; charset="UTF-8"', 'Content-Length': '579'}, 'Data': b'<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">\r\n<ipAddress>192.168.19.205</ipAddress>\r\n<ipv6Address>2a02:a45f:c5e:1:82be:afff:fe97:e2bf</ipv6Address>\r\n<portNo>80</portNo>\r\n<protocol>HTTP</protocol>\r\n<macAddress>80:be:af:97:e2:bf</macAddress>\r\n<channelID>1</channelID>\r\n<dateTime>2024-02-11T14:44:59+01:00</dateTime>\r\n<activePostCount>1</activePostCount>\r\n<eventType>videoloss</eventType>\r\n<eventState>inactive</eventState>\r\n<eventDescription>videoloss alarm</eventDescription>\r\n<channelName>Tuin</channelName>\r\n</EventNotificationAlert>\r\n'}
2024-02-11 14:45:03.138 Error: malformed request response received (verb: --boundary/--boundary)
An example of the datastream:
Code: Select all
| --boundary
| Content-Type: application/xml; charset="UTF-8"
| Content-Length: 579
|
| <EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
| <ipAddress>192.168.19.205</ipAddress>
| <ipv6Address>xxxx:xxxx:xxxx:x:xxxx:xxxx:xxxx:xxxx</ipv6Address>
| <portNo>80</portNo>
| <protocol>HTTP</protocol>
| <macAddress>80:be:af:97:e2:bf</macAddress>
| <channelID>1</channelID>
| <dateTime>2024-02-11T14:55:21+01:00</dateTime>
| <activePostCount>1</activePostCount>
| <eventType>videoloss</eventType>
|
| <eventState>inactive</eventState>
| <eventDescription>videoloss alarm</eventDescription>
| <channelName>Tuin</channelName>
| </EventNotificationAlert>
| --boundary
| Content-Type: application/xml; charset="UTF-8"
| Content-Length: 579
|
| <EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
| <ipAddress>192.168.19.205</ipAddress>
| <ipv6Address>xxxx:xxxx:xxxx:x:xxxx:xxxx:xxxx:xxxx</ipv6Address>
| <portNo>80</portNo>
| <protocol>HTTP</protocol>
| <macAddress>80:be:af:97:e2:bf</macAddress>
| <channelID>1</channelID>
| <dateTime>2024-02-11T14:55:31+01:00</dateTime>
| <activePostCount>1</activePostCount>
| <eventType>videoloss</eventType>
| <eventState>inactive</eventState>
| <eventDescription>videoloss alarm</eventDescription>
| <channelName>Tuin</channelName>
| </EventNotificationAlert>
| --boundary
| Content-Type: application/xml; charset="UTF-8"
| Content-Length: 579
|
| <EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
| <ipAddress>192.168.19.205</ipAddress>
| <ipv6Address>xxxx:xxxx:xxxx:x:xxxx:xxxx:xxxx:xxxx</ipv6Address>
| <portNo>80</portNo>
| <protocol>HTTP</protocol>
| <macAddress>80:be:af:97:e2:bf</macAddress>
| <channelID>1</channelID>
| <dateTime>2024-02-11T14:55:41+01:00</dateTime>
| <activePostCount>1</activePostCount>
| <eventType>videoloss</eventType>
| <eventState>inactive</eventState>
| <eventDescription>videoloss alarm</eventDescription>
| <channelName>Tuin</channelName>
| </EventNotificationAlert>
| --boundary