kushagharahi / homebridge-dahua-alerts

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

Amcrest IP3M-943B - Lots of 400 Bad Request errors when trying to connect #21

Closed magic7s closed 3 years ago

magic7s commented 3 years ago

The errors are filling up my logs, but everything is working. Can you move this error to debug?

This just scrolls all day.

[29/08/2021, 11:06:26] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 11:06:26] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 11:06:36] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 11:06:36] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 11:06:46] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 11:06:46] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 11:06:56] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 11:06:56] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 11:07:06] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 11:07:06] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 11:07:16] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 11:07:16] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 11:07:26] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 11:07:26] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 11:07:36] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 11:07:36] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 11:07:46] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 11:07:46] [dahua-alerts] Error Received (for more info enable debug logging)
kushagharahi commented 3 years ago

No because these logs indicate an error was received. It's not a debug log. The logs you have provided do not indicate that the error is coming from that line of code either. This is the log in question printed in the snippet above, which is a catch all for all errors: https://github.com/kushagharahi/homebridge-dahua-alerts/blob/master/src/index.ts#L43

Can you enable debug logging so we can see what the error is?

kushagharahi commented 3 years ago

I'm getting constant scrolling errors but it's working. I have two cameras that are receiving motion update and it's great. I've done a pcap on the network interface, and yes the plugin keeps trying the url but receives 40X from the camera.

FYI - no NVR, only two cameras.

[29/08/2021, 20:29:02] Loaded plugin: homebridge-dahua-alerts@1.1.5
[29/08/2021, 20:29:02] Registering platform 'homebridge-dahua-alerts.dahua-alerts'
[29/08/2021, 20:29:12] [dahua-alerts] Initializing dahua-alerts platform...
[29/08/2021, 20:29:13] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 20:29:13] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request
[29/08/2021, 20:29:13] [dahua-alerts] Reconnecting in 10s.
[29/08/2021, 20:29:23] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 20:29:23] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request
[29/08/2021, 20:29:23] [dahua-alerts] Reconnecting in 10s.
[29/08/2021, 20:29:33] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 20:29:33] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request
[29/08/2021, 20:29:33] [dahua-alerts] Reconnecting in 10s.
[29/08/2021, 20:29:43] [dahua-alerts] Socket connection timed out or closed by NVR.
[29/08/2021, 20:29:43] [dahua-alerts] Reconnecting in 1s.
[29/08/2021, 20:29:49] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 20:29:49] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request
[29/08/2021, 20:29:49] [dahua-alerts] Reconnecting in 10s.
[29/08/2021, 20:29:49] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[29/08/2021, 20:29:49] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[29/08/2021, 20:29:59] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 20:29:59] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request
[29/08/2021, 20:29:59] [dahua-alerts] Reconnecting in 10s.
[29/08/2021, 20:30:09] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 20:30:09] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request
[29/08/2021, 20:30:09] [dahua-alerts] Reconnecting in 10s.
[29/08/2021, 20:30:23] [dahua-alerts] Socket connection timed out or closed by NVR.
[29/08/2021, 20:30:23] [dahua-alerts] Reconnecting in 1s.
[29/08/2021, 20:30:24] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 20:30:24] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request
[29/08/2021, 20:30:24] [dahua-alerts] Reconnecting in 10s.
[29/08/2021, 20:30:24] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[29/08/2021, 20:30:24] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[29/08/2021, 20:30:34] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 20:30:34] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request
[29/08/2021, 20:30:34] [dahua-alerts] Reconnecting in 10s.
[29/08/2021, 20:30:44] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 20:30:44] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request
[29/08/2021, 20:30:44] [dahua-alerts] Reconnecting in 10s.
[29/08/2021, 20:30:54] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 20:30:54] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request
[29/08/2021, 20:30:54] [dahua-alerts] Reconnecting in 10s.
[29/08/2021, 20:30:54] [dahua-alerts] Socket connection timed out or closed by NVR.
[29/08/2021, 20:30:54] [dahua-alerts] Reconnecting in 1s.
[29/08/2021, 20:30:56] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[29/08/2021, 20:30:56] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[29/08/2021, 20:31:04] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 20:31:04] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request
[29/08/2021, 20:31:04] [dahua-alerts] Reconnecting in 10s.
[29/08/2021, 20:31:14] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 20:31:14] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request
[29/08/2021, 20:31:14] [dahua-alerts] Reconnecting in 10s.
[29/08/2021, 20:31:24] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 20:31:24] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request
[29/08/2021, 20:31:24] [dahua-alerts] Reconnecting in 10s.
[29/08/2021, 20:31:26] [dahua-alerts] Socket connection timed out or closed by NVR.
[29/08/2021, 20:31:26] [dahua-alerts] Reconnecting in 1s.
[29/08/2021, 20:31:27] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[29/08/2021, 20:31:27] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[29/08/2021, 20:31:34] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 20:31:34] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request
[29/08/2021, 20:31:34] [dahua-alerts] Reconnecting in 10s.
[29/08/2021, 20:31:44] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 20:31:44] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request
[29/08/2021, 20:31:44] [dahua-alerts] Reconnecting in 10s.
[29/08/2021, 20:31:55] [dahua-alerts] Error Received (for more info enable debug logging)
[29/08/2021, 20:31:55] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request
[29/08/2021, 20:31:55] [dahua-alerts] Reconnecting in 10s.
[29/08/2021, 20:31:57] [dahua-alerts] Socket connection timed out or closed by NVR.
[29/08/2021, 20:31:57] [dahua-alerts] Reconnecting in 1s.
[29/08/2021, 20:31:58] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[29/08/2021, 20:31:58] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
kushagharahi commented 3 years ago

Moved the conversation over from your other issue into this thread so we can keep it all in one issue.

So both cameras are giving you motion alerts? It sort of looks like one camera is giving 400 every connection attempt cause if you notice:

I would like to verify that both cameras are doing this 4XX behavior. The way that this code is written, unless there's a major bug this plugin won't be able to forward motion alerts if a 4XX is returned. It would be helpful if you manually figured this out by removing a camera from the config at a time. With some refactoring, I can get the logs to show the camera name/index but it's kinda a big refactor I won't have time to do until next weekend or weekend after next.

I did add one debug log to show the entire error response in order to see if the cameras are returning something more descriptive than bad request. Could you please replace the dist folder contents in homebridge\node_modules\homebridge-dahua-alerts\dist with the contents of this zip. Then restart homebridge. Then post the new debug logs.

dist.zip

magic7s commented 3 years ago

Here is a pcap from homebridge. Sorry for the screenshot, the actual pcap file would like have my password in it.

As you can see, both are producing the same behavior. They are the same model and configured the same, so I would expect the same results.

My theory is the first request opens the long lived tcp connection and continues to receive motion alerts on this channel, but the plugin keeps trying to open new tcp connections using the same token received from the first request and that is what is causing the 40X errors. Just my theory. I'll attempt to add the zip file shortly.

Screen Shot 2021-08-30 at 12 44 10 PM
magic7s commented 3 years ago

I replaced the dist folder and restated homebridge with debug on. Here is the log below.

[30/08/2021, 15:45:11] [HB Supervisor] Starting Homebridge with custom env: {"DEBUG":"dahua-alerts"}
[30/08/2021, 15:45:17] Loaded plugin: homebridge-dahua-alerts@1.1.5
[30/08/2021, 15:45:17] Registering platform 'homebridge-dahua-alerts.dahua-alerts'
[30/08/2021, 15:45:27] [dahua-alerts] Initializing dahua-alerts platform...
[30/08/2021, 15:45:28] [dahua-alerts] Error Received (for more info enable debug logging)
[30/08/2021, 15:45:28] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[30/08/2021, 15:45:28] [dahua-alerts] Reconnecting in 10s.
[30/08/2021, 15:45:28] [dahua-alerts] Error Received (for more info enable debug logging)
[30/08/2021, 15:45:28] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[30/08/2021, 15:45:28] [dahua-alerts] Reconnecting in 10s.
[30/08/2021, 15:45:41] [dahua-alerts] Error Received (for more info enable debug logging)
[30/08/2021, 15:45:41] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[30/08/2021, 15:45:41] [dahua-alerts] Reconnecting in 10s.
[30/08/2021, 15:45:41] [dahua-alerts] Error Received (for more info enable debug logging)
[30/08/2021, 15:45:41] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[30/08/2021, 15:45:41] [dahua-alerts] Reconnecting in 10s.
[30/08/2021, 15:45:51] [dahua-alerts] Error Received (for more info enable debug logging)
[30/08/2021, 15:45:51] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[30/08/2021, 15:45:51] [dahua-alerts] Reconnecting in 10s.
[30/08/2021, 15:45:51] [dahua-alerts] Error Received (for more info enable debug logging)
[30/08/2021, 15:45:51] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[30/08/2021, 15:45:51] [dahua-alerts] Reconnecting in 10s.
[30/08/2021, 15:46:01] [dahua-alerts] Error Received (for more info enable debug logging)
[30/08/2021, 15:46:01] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[30/08/2021, 15:46:01] [dahua-alerts] Reconnecting in 10s.
[30/08/2021, 15:46:01] [dahua-alerts] Error Received (for more info enable debug logging)
[30/08/2021, 15:46:01] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[30/08/2021, 15:46:01] [dahua-alerts] Reconnecting in 10s.
[30/08/2021, 15:46:11] [dahua-alerts] Error Received (for more info enable debug logging)
[30/08/2021, 15:46:11] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[30/08/2021, 15:46:11] [dahua-alerts] Reconnecting in 10s.
[30/08/2021, 15:46:11] [dahua-alerts] Error Received (for more info enable debug logging)
[30/08/2021, 15:46:11] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[30/08/2021, 15:46:11] [dahua-alerts] Reconnecting in 10s.
[30/08/2021, 15:46:21] [dahua-alerts] Error Received (for more info enable debug logging)
[30/08/2021, 15:46:21] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[30/08/2021, 15:46:21] [dahua-alerts] Reconnecting in 10s.
[30/08/2021, 15:46:22] [dahua-alerts] Error Received (for more info enable debug logging)
[30/08/2021, 15:46:22] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[30/08/2021, 15:46:22] [dahua-alerts] Reconnecting in 10s.
kushagharahi commented 3 years ago

I only see .173 giving 401 and 400 in your PCAP .137 looks healthy, what do you think?

IMO it looks like .173 has bad credentials perhaps

kushagharahi commented 3 years ago

~Kind of interesting that the 401s don't appear in the HB logs~| 401s don't appear because the 401 is part of the digest auth flow

magic7s commented 3 years ago

Same pcap file, just a different filter.

Screen Shot 2021-08-30 at 4 11 05 PM
kushagharahi commented 3 years ago

Oh my mistake, I was looking at Destination, not source

kushagharahi commented 3 years ago

dist (2).zip

Can you try this? Threw a JSON.Stringify to get the string output of that object

kushagharahi commented 3 years ago

If your hunch is correct, perhaps this could be the issue https://github.com/axios/axios/issues/2143

This plugin is on an older axios version than when the bugfix happened.

kushagharahi commented 3 years ago

Also, while the reconnection 400 loop is happening, can you trigger a motion alert on each camera to see on the debug logs if possible please?

iRayanKhan commented 3 years ago

I am trying this plugin out again, and am also getting this error repeatedly:

[30/08/2021, 23:15:17] [dahua-alerts] Error Received (for more info enable debug logging)

I have an NVR, and 4 Cameras.

magic7s commented 3 years ago

dist (2).zip

Can you try this? Threw a JSON.Stringify to get the string output of that object

I'm not seeing the constant scrolling. However I am seeing new errors.

(node:745) UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Socket'
    |     property '_httpMessage' -> object with constructor 'ClientRequest'
    --- property 'socket' closes the circle
    at JSON.stringify (<anonymous>)
    at /usr/local/lib/node_modules/homebridge-dahua-alerts/src/dahua.ts:135:165
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:745) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)
(node:745) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:745) UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Socket'
    |     property '_httpMessage' -> object with constructor 'ClientRequest'
    --- property 'socket' closes the circle
    at JSON.stringify (<anonymous>)
    at /usr/local/lib/node_modules/homebridge-dahua-alerts/src/dahua.ts:135:165
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
(node:745) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 6)
kushagharahi commented 3 years ago

I am trying this plugin out again, and am also getting this error repeatedly:

[30/08/2021, 23:15:17] [dahua-alerts] Error Received (for more info enable debug logging)

I have an NVR, and 4 Cameras.

Can you please post debug logs here if they are the same as OPs issue, otherwise open a new thread?

kushagharahi commented 3 years ago

@magic7s Thank you for your patience while I try to unsuccessfully print out the error response message. Could you please try this and post the subsequent logs? dist (3).zip

magic7s commented 3 years ago

with dist (3).zip

[03/09/2021, 09:15:05] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 09:15:05] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 09:15:05] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 09:15:05] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 09:15:05] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 09:15:05] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 09:15:15] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 09:15:15] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 09:15:15] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 09:15:15] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 09:15:15] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 09:15:15] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 09:15:25] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 09:15:25] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 09:15:25] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 09:15:25] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 09:15:25] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 09:15:25] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 09:15:35] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 09:15:35] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 09:15:35] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 09:15:35] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 09:15:35] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 09:15:35] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 09:15:45] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 09:15:45] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 09:15:45] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 09:15:45] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 09:15:45] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 09:15:45] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 09:15:55] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 09:15:55] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 09:15:55] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 09:15:55] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 09:15:55] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 09:16:05] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 09:16:05] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 09:16:05] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 09:16:07] [dahua-alerts] Response recieved: -- myboundary
, mapped to camera Front Door Camera] Video Motion Ended on index: 0
[03/09/2021, 09:16:07] [dahua-alerts] Reset motion for Front Door Camera posted to homebridge-camera-ffmpeg, received { error: false, message: 'Motion switched off.' }
[03/09/2021, 09:16:15] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 09:16:15] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 09:16:15] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 09:16:25] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 09:16:25] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 09:16:25] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 09:16:36] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 09:16:36] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 09:16:36] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 09:16:37] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 09:16:37] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 09:16:38] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 09:16:38] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 09:16:46] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 09:16:46] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 09:16:46] [dahua-alerts] Reconnecting in 10s.
kushagharahi commented 3 years ago

Sorry I'm having so much trouble getting the response body log to print. Thank you for posting a log with a motion alert

[03/09/2021, 09:16:07] [dahua-alerts] Response recieved: -- myboundary
, mapped to camera Front Door Camera] Video Motion Ended on index: 0

👍

Let's try something, currently the http requests package this plugin uses is axios, this plugin is bound to the 0.19.* version, since then there have been two minor patches and now axios is on 0.21.*. I'd like to upgrade your axios package version to 0.21.1, which is the latest and includes several socket connection fixes according to the changelog.

Could you please replace the axios folder contents in homebridge\node_modules\homebridge-dahua-alerts\node_modules\axios with the contents of this zip. Then restart homebridge. Then post the new debug logs please

axios.zip

kushagharahi commented 3 years ago

Could you also make sure your server time and camera time are the same? This plugin uses digest auth and it's really important that the camera time is correct (matches the server time). Otherwise you will get a 400 after a 401

magic7s commented 3 years ago

With new axios.zip

[03/09/2021, 14:10:01] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:10:34] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:10:34] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:10:34] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:10:34] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 14:10:34] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:10:35] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:10:35] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:10:44] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:10:44] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 14:10:44] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:10:54] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:10:54] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 14:10:54] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:11:04] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:11:04] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 14:11:04] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:11:05] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:11:05] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:11:06] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:11:06] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:11:14] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:11:14] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 14:11:14] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:11:24] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:11:24] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 14:11:24] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:11:34] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:11:34] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 14:11:34] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:11:36] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:11:36] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:11:38] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:11:38] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:11:44] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:11:44] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 14:11:44] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:11:54] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:11:54] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 14:11:54] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:12:04] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:12:04] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 14:12:04] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:12:08] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:12:08] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:12:09] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:12:09] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:12:14] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:12:14] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 14:12:14] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:12:25] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:12:25] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 14:12:25] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:12:35] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:12:35] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 14:12:35] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:12:39] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:12:39] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:12:40] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:12:40] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:12:45] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:12:45] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 14:12:45] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:12:55] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:12:55] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 14:12:55] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:13:05] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:13:05] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request MessageBody [object Object]
[03/09/2021, 14:13:05] [dahua-alerts] Reconnecting in 10s.

The 200 OK logs multi-line and I cannot grep for it very well. Here is an example.

[03/09/2021, 14:13:42] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Expires: Thu, 01 Dec 2099 16:00:00 GMT
Connection: Keep-Alive
Content-Type: multipart/x-mixed-replace; boundary=myboundary

[03/09/2021, 14:13:42] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Expires: Thu, 01 Dec 2099 16:00:00 GMT
Connection: Keep-Alive
Content-Type: multipart/x-mixed-replace; boundary=myboundary
magic7s commented 3 years ago

Could you also make sure your server time and camera time are the same? This plugin uses digest auth and it's really important that the camera time is correct (matches the server time). Otherwise you will get a 400 after a 401

Both are sync with NTP servers. Time stamps match.

magic7s commented 3 years ago

FYI - I am using HTTP, not HTTPS/TLS.

kushagharahi commented 3 years ago

Let's try this. This adds host (ip) logging to the error message and does a return if unhanded event comes through (it did nothing before)

dist (4).zip

I doubt this will change anything and as usual I appreciate your patience in resolving this issue. I do not have the device so I have to go through you

magic7s commented 3 years ago

No prob, thanks for troubleshooting.

[03/09/2021, 14:38:33] [HB Supervisor] Starting Homebridge with custom env: {"DEBUG":"dahua-alerts"}
[03/09/2021, 14:38:39] Loaded plugin: homebridge-dahua-alerts@1.1.5
[03/09/2021, 14:38:39] Registering platform 'homebridge-dahua-alerts.dahua-alerts'
[03/09/2021, 14:38:47] [dahua-alerts] Initializing dahua-alerts platform...
[03/09/2021, 14:38:48] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:38:48] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.123
[03/09/2021, 14:38:48] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:38:48] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:38:48] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:38:48] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:39:01] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:39:01] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.123
[03/09/2021, 14:39:01] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:39:01] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:39:01] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:39:01] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:39:11] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:39:11] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.123
[03/09/2021, 14:39:11] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:39:11] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:39:11] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:39:11] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:39:22] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:39:22] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.123
[03/09/2021, 14:39:22] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:39:22] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:39:22] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:39:22] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:39:32] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:39:32] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.123
[03/09/2021, 14:39:32] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:39:32] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:39:32] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:39:32] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:39:42] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:39:42] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:39:42] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:39:42] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:39:42] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.123
[03/09/2021, 14:39:42] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:39:52] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:39:52] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:39:52] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:39:52] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:39:52] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.123
[03/09/2021, 14:39:52] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:40:02] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:40:02] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.123
[03/09/2021, 14:40:02] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:40:02] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:40:02] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:40:02] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:40:12] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:40:12] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.123
[03/09/2021, 14:40:12] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:40:12] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:40:12] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:40:12] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:40:23] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:40:23] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:40:23] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.123
[03/09/2021, 14:40:23] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:40:23] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:40:23] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:40:33] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:40:33] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:40:33] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:40:33] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:40:33] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:40:38] [dahua-alerts] Response recieved: -- myboundary
, mapped to camera Front Door Camera] Video Motion Ended on index: 0
[03/09/2021, 14:40:38] [dahua-alerts] Reset motion for Front Door Camera posted to homebridge-camera-ffmpeg, received { error: false, message: 'Motion switched off.' }
[03/09/2021, 14:40:43] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:40:43] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:40:43] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:40:53] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:40:53] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:40:53] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:41:03] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:41:03] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:41:03] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:41:08] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:41:08] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:41:09] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:41:09] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:41:13] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:41:13] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:41:29] [dahua-alerts] Response recieved: -- myboundary
, mapped to camera Back Door Cameras] Video Motion Ended on index: 0
[03/09/2021, 14:41:29] [dahua-alerts] Reset motion for Back Door Camera posted to homebridge-camera-ffmpeg, received { error: false, message: 'Motion switched off.' }
[03/09/2021, 14:41:42] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:41:42] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:41:43] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:41:43] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:41:59] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:41:59] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:42:00] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:42:00] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:42:13] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:42:13] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:42:15] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:42:15] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
magic7s commented 3 years ago

Not sure if you changed anything on the last drop (other than logging) but I'm not seeing the constant scroll right now. I don't know if I am talking too soon....

kushagharahi commented 3 years ago

I made this exception return something: Could not parse event data:. Where it didn't return anything before. Perhaps since it didn't return anything the socket was kept open while the plugin thought the socket connection closed? So then when it went to reconnect the camera wasn't happy with multiple socket connections?

Unsure, I'm trying to get a JS expert friend to take a look to see if he can confirm

magic7s commented 3 years ago

Spoke too soon... so far errors on only the .137 camera.

[03/09/2021, 14:42:15] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:42:15] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:42:30] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:42:30] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:42:31] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:42:31] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:42:45] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:42:45] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:42:46] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:42:46] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:43:01] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:43:01] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:43:02] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:43:02] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:43:16] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:43:16] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:43:17] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:43:17] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:43:32] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:43:32] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:43:33] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:43:33] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:43:47] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:43:47] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:43:48] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:43:48] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:44:04] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:44:04] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:44:05] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:44:05] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:44:18] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:44:18] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:44:19] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:44:19] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:44:35] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:44:35] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:44:36] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:44:36] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:44:49] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:44:49] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:44:50] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:44:50] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:45:06] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:45:06] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:45:07] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:45:07] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:45:20] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:45:20] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:45:21] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:45:21] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:45:37] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:45:37] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:45:38] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:45:38] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:45:51] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:45:51] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:45:52] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:45:52] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:46:08] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:46:08] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:46:09] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:46:09] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:46:22] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:46:22] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:46:23] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:46:23] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:46:39] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:46:39] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:46:40] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:46:40] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:46:53] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:46:53] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:46:54] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:46:54] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:47:10] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:47:10] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:47:11] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:47:11] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:47:26] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:47:26] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:47:27] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:47:27] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:47:41] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:47:41] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:47:42] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:47:42] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:47:57] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:47:57] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:47:58] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:47:58] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:48:12] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:48:12] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:48:13] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:48:13] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:48:23] [dahua-alerts] Response recieved: -- myboundary
, mapped to camera Front Door Camera] Video Motion Detected on index: 0
[03/09/2021, 14:48:23] [dahua-alerts] Motion for Front Door Camera posted to homebridge-camera-ffmpeg, received { error: false, message: 'Motion switched on.', cooldownActive: false }
[03/09/2021, 14:48:37] [dahua-alerts] Response recieved: -- myboundary
, mapped to camera Front Door Camera] Video Motion Ended on index: 0
[03/09/2021, 14:48:37] [dahua-alerts] Reset motion for Front Door Camera posted to homebridge-camera-ffmpeg, received { error: false, message: 'Motion switched off.' }
[03/09/2021, 14:48:43] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:48:43] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:48:46] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:48:46] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:49:07] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:49:07] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:49:08] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:49:08] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:49:16] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:49:16] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:49:17] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:49:17] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:49:38] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:49:38] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:49:39] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:49:39] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:49:47] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:49:47] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:49:48] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:49:48] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:50:09] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:50:09] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:50:11] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:50:11] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:50:19] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:50:19] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:50:20] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:50:20] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:50:41] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:50:41] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:50:42] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:50:42] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:50:50] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:50:50] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:50:51] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:50:51] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:51:12] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:51:12] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:51:13] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:51:13] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:51:21] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:51:21] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:51:22] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:51:22] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:51:43] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:51:43] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:51:44] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:51:44] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:51:52] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:51:52] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:52:14] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:52:14] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:52:15] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:52:15] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:52:24] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:52:24] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:52:25] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:52:25] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:52:45] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:52:45] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:52:46] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:52:46] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:52:56] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:52:56] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:52:57] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:52:57] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:53:17] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:53:17] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:53:18] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:53:18] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:53:27] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:53:27] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:53:28] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:53:28] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:53:48] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:53:48] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:53:49] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:53:49] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:53:58] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:53:58] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:53:59] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:53:59] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:54:22] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:54:22] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:54:23] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:54:23] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:54:29] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:54:29] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:54:30] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:54:30] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:54:53] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:54:53] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:54:54] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:54:54] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:55:00] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:55:00] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:55:02] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:55:02] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:55:24] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:55:24] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:55:26] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:55:26] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:55:32] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:55:32] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:55:33] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:55:33] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:55:56] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:55:56] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:55:57] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:55:57] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:56:03] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:56:03] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:56:04] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:56:04] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:56:27] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:56:27] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:56:28] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:56:28] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:56:34] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:56:34] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:56:35] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:56:35] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:56:35] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:56:45] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:56:45] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:56:45] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:56:58] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:56:58] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:56:58] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:56:58] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:56:58] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:56:59] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:56:59] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:57:08] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:57:08] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:57:08] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:57:18] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:57:18] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:57:18] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:57:28] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:57:28] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:57:28] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:57:29] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:57:29] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:57:30] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:57:30] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:57:38] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:57:38] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:57:38] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:57:49] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:57:49] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:57:49] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:57:59] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:57:59] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:57:59] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:58:00] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:58:00] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:58:02] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:58:02] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:58:10] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:58:10] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:58:10] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:58:20] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:58:20] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:58:20] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:58:30] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:58:30] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:58:30] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:58:32] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:58:32] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:58:33] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:58:33] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:58:40] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:58:40] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:58:40] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:58:50] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:58:50] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:58:50] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:59:00] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:59:00] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:59:00] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:59:03] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:59:03] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:59:04] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:59:04] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:59:10] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:59:10] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:59:10] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:59:20] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:59:20] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:59:20] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:59:30] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:59:30] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:59:30] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 14:59:34] [dahua-alerts] Socket connection timed out or closed by NVR.
[03/09/2021, 14:59:34] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 14:59:35] [dahua-alerts] Response recieved: HTTP/1.1 200 OK
[03/09/2021, 14:59:35] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 14:59:41] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 14:59:41] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 14:59:41] [dahua-alerts] Reconnecting in 10s.
magic7s commented 3 years ago

Here comes the .123 camera

[03/09/2021, 15:03:15] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 15:03:15] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.123
[03/09/2021, 15:03:15] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:03:24] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 15:03:24] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 15:03:24] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:03:25] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 15:03:25] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.123
[03/09/2021, 15:03:25] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:03:34] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 15:03:34] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.137
[03/09/2021, 15:03:34] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:03:35] [dahua-alerts] Error Received (for more info enable debug logging)
[03/09/2021, 15:03:35] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request Host: 192.168.128.123
[03/09/2021, 15:03:35] [dahua-alerts] Reconnecting in 10s.
kushagharahi commented 3 years ago

dist (5).zip

More logging! Thanks again

magic7s commented 3 years ago

Np, is there any way to use git to sync your changes? I don't know node very well, but can I sync the dist directory to a branch or something?

kushagharahi commented 3 years ago

Sure, check out the branch debug-4xx, it's the dist folder there

magic7s commented 3 years ago
[03/09/2021, 15:21:50] [HB Supervisor] Starting Homebridge with custom env: {"DEBUG":"dahua-alerts"}
[03/09/2021, 15:21:56] Loaded plugin: homebridge-dahua-alerts@1.1.5
[03/09/2021, 15:21:56] Registering platform 'homebridge-dahua-alerts.dahua-alerts'
[03/09/2021, 15:22:04] [dahua-alerts] Initializing dahua-alerts platform...
[03/09/2021, 15:22:05] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.123, sending digest auth. Count: 1
[03/09/2021, 15:22:05] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.137, sending digest auth. Count: 1
[03/09/2021, 15:22:05] [dahua-alerts] Error received from host: 192.168.128.137 (for more info enable debug logging)
[03/09/2021, 15:22:05] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request on Host: 192.168.128.137
[03/09/2021, 15:22:05] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:22:05] [dahua-alerts] Error received from host: 192.168.128.123 (for more info enable debug logging)
[03/09/2021, 15:22:05] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request on Host: 192.168.128.123
[03/09/2021, 15:22:05] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:22:18] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.123, sending digest auth. Count: 1
[03/09/2021, 15:22:18] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.137, sending digest auth. Count: 1
[03/09/2021, 15:22:18] [dahua-alerts] Error received from host: 192.168.128.137 (for more info enable debug logging)
[03/09/2021, 15:22:18] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request on Host: 192.168.128.137
[03/09/2021, 15:22:18] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:22:18] [dahua-alerts] Error received from host: 192.168.128.123 (for more info enable debug logging)
[03/09/2021, 15:22:18] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request on Host: 192.168.128.123
[03/09/2021, 15:22:18] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:22:28] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.137, sending digest auth. Count: 1
[03/09/2021, 15:22:28] [dahua-alerts] Error received from host: 192.168.128.137 (for more info enable debug logging)
[03/09/2021, 15:22:28] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request on Host: 192.168.128.137
[03/09/2021, 15:22:28] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:22:28] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.123, sending digest auth. Count: 1
[03/09/2021, 15:22:28] [dahua-alerts] Error received from host: 192.168.128.123 (for more info enable debug logging)
[03/09/2021, 15:22:28] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request on Host: 192.168.128.123
[03/09/2021, 15:22:28] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:22:38] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.137, sending digest auth. Count: 1
[03/09/2021, 15:22:38] [dahua-alerts] Error received from host: 192.168.128.137 (for more info enable debug logging)
[03/09/2021, 15:22:38] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request on Host: 192.168.128.137
[03/09/2021, 15:22:38] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:22:38] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.123, sending digest auth. Count: 1
[03/09/2021, 15:22:38] [dahua-alerts] Error received from host: 192.168.128.123 (for more info enable debug logging)
[03/09/2021, 15:22:38] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request on Host: 192.168.128.123
[03/09/2021, 15:22:38] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:22:48] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.137, sending digest auth. Count: 1
[03/09/2021, 15:22:48] [dahua-alerts] Error received from host: 192.168.128.137 (for more info enable debug logging)
[03/09/2021, 15:22:48] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request on Host: 192.168.128.137
[03/09/2021, 15:22:48] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:22:48] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.123, sending digest auth. Count: 1
[03/09/2021, 15:22:48] [dahua-alerts] Error received from host: 192.168.128.123 (for more info enable debug logging)
[03/09/2021, 15:22:48] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request on Host: 192.168.128.123
[03/09/2021, 15:22:48] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:22:58] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.137, sending digest auth. Count: 1
[03/09/2021, 15:22:58] [dahua-alerts] Error received from host: 192.168.128.137 (for more info enable debug logging)
[03/09/2021, 15:22:58] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request on Host: 192.168.128.137
[03/09/2021, 15:22:58] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:22:59] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.123, sending digest auth. Count: 1
[03/09/2021, 15:22:59] [dahua-alerts] Error received from host: 192.168.128.123 (for more info enable debug logging)
[03/09/2021, 15:22:59] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request on Host: 192.168.128.123
[03/09/2021, 15:22:59] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:23:08] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.137, sending digest auth. Count: 1
[03/09/2021, 15:23:08] [dahua-alerts] Error received from host: 192.168.128.137 (for more info enable debug logging)
[03/09/2021, 15:23:08] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request on Host: 192.168.128.137
[03/09/2021, 15:23:08] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:23:09] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.123, sending digest auth. Count: 1
[03/09/2021, 15:23:09] [dahua-alerts] Error received from host: 192.168.128.123 (for more info enable debug logging)
[03/09/2021, 15:23:09] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request on Host: 192.168.128.123
[03/09/2021, 15:23:09] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:23:18] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.137, sending digest auth. Count: 1
[03/09/2021, 15:23:19] [dahua-alerts] Error received from host: 192.168.128.137 (for more info enable debug logging)
[03/09/2021, 15:23:19] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request on Host: 192.168.128.137
[03/09/2021, 15:23:19] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:23:19] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.123, sending digest auth. Count: 1
[03/09/2021, 15:23:19] [dahua-alerts] Error received from host: 192.168.128.123 (for more info enable debug logging)
[03/09/2021, 15:23:19] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request on Host: 192.168.128.123
[03/09/2021, 15:23:19] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:23:31] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.123, sending digest auth. Count: 1
[03/09/2021, 15:23:31] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.137, sending digest auth. Count: 1
[03/09/2021, 15:23:31] [dahua-alerts] Response recieved on host: 192.168.128.123: HTTP/1.1 200 OK
[03/09/2021, 15:23:31] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 15:23:31] [dahua-alerts] Error received from host: 192.168.128.137 (for more info enable debug logging)
[03/09/2021, 15:23:31] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request on Host: 192.168.128.137
[03/09/2021, 15:23:31] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:23:40] [dahua-alerts] Response recieved on host: 192.168.128.123: -- myboundary
, mapped to camera Front Door Camera] Video Motion Ended on index: 0
[03/09/2021, 15:23:40] [dahua-alerts] Reset motion for Front Door Camera posted to homebridge-camera-ffmpeg, received { error: false, message: 'Motion switched off.' }
[03/09/2021, 15:23:41] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.137, sending digest auth. Count: 1
[03/09/2021, 15:23:41] [dahua-alerts] Error received from host: 192.168.128.137 (for more info enable debug logging)
[03/09/2021, 15:23:41] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request on Host: 192.168.128.137
[03/09/2021, 15:23:41] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:23:51] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.137, sending digest auth. Count: 1
[03/09/2021, 15:23:51] [dahua-alerts] Error received from host: 192.168.128.137 (for more info enable debug logging)
[03/09/2021, 15:23:51] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request on Host: 192.168.128.137
[03/09/2021, 15:23:51] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:23:58] [dahua-alerts] Response recieved on host: 192.168.128.123: -- myboundary
, mapped to camera Front Door Camera] Video Motion Detected on index: 0
[03/09/2021, 15:23:58] [dahua-alerts] Motion for Front Door Camera posted to homebridge-camera-ffmpeg, received { error: false, message: 'Motion switched on.', cooldownActive: false }
[03/09/2021, 15:24:01] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.137, sending digest auth. Count: 1
[03/09/2021, 15:24:01] [dahua-alerts] Error received from host: 192.168.128.137 (for more info enable debug logging)
[03/09/2021, 15:24:01] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request on Host: 192.168.128.137
[03/09/2021, 15:24:01] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:24:07] [dahua-alerts] Response recieved on host: 192.168.128.123: -- myboundary
, mapped to camera Front Door Camera] Video Motion Ended on index: 0
[03/09/2021, 15:24:07] [dahua-alerts] Reset motion for Front Door Camera posted to homebridge-camera-ffmpeg, received { error: false, message: 'Motion switched off.' }
[03/09/2021, 15:24:11] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.137, sending digest auth. Count: 1
[03/09/2021, 15:24:11] [dahua-alerts] Error received from host: 192.168.128.137 (for more info enable debug logging)
[03/09/2021, 15:24:11] [dahua-alerts] Error Details: Status Code: 400 Response: Bad Request on Host: 192.168.128.137
[03/09/2021, 15:24:11] [dahua-alerts] Reconnecting in 10s.
[03/09/2021, 15:24:21] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.137, sending digest auth. Count: 1
[03/09/2021, 15:24:22] [dahua-alerts] Response recieved on host: 192.168.128.137: HTTP/1.1 200 OK
[03/09/2021, 15:24:22] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 15:24:37] [dahua-alerts] Socket connection timed out or closed on host: 192.168.128.123
[03/09/2021, 15:24:37] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 15:24:38] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.123, sending digest auth. Count: 1
[03/09/2021, 15:24:38] [dahua-alerts] Response recieved on host: 192.168.128.123: HTTP/1.1 200 OK
[03/09/2021, 15:24:38] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 15:24:52] [dahua-alerts] Socket connection timed out or closed on host: 192.168.128.137
[03/09/2021, 15:24:52] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 15:24:53] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.137, sending digest auth. Count: 1
[03/09/2021, 15:24:53] [dahua-alerts] Response recieved on host: 192.168.128.137: HTTP/1.1 200 OK
[03/09/2021, 15:24:53] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 15:25:08] [dahua-alerts] Socket connection timed out or closed on host: 192.168.128.123
[03/09/2021, 15:25:08] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 15:25:09] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.123, sending digest auth. Count: 1
[03/09/2021, 15:25:09] [dahua-alerts] Response recieved on host: 192.168.128.123: HTTP/1.1 200 OK
[03/09/2021, 15:25:09] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 15:25:23] [dahua-alerts] Socket connection timed out or closed on host: 192.168.128.137
[03/09/2021, 15:25:23] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 15:25:24] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.137, sending digest auth. Count: 1
[03/09/2021, 15:25:24] [dahua-alerts] Response recieved on host: 192.168.128.137: HTTP/1.1 200 OK
[03/09/2021, 15:25:24] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 15:25:39] [dahua-alerts] Socket connection timed out or closed on host: 192.168.128.123
[03/09/2021, 15:25:39] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 15:25:40] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.123, sending digest auth. Count: 1
[03/09/2021, 15:25:40] [dahua-alerts] Response recieved on host: 192.168.128.123: HTTP/1.1 200 OK
[03/09/2021, 15:25:40] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
[03/09/2021, 15:25:55] [dahua-alerts] Socket connection timed out or closed on host: 192.168.128.137
[03/09/2021, 15:25:55] [dahua-alerts] Reconnecting in 1s.
[03/09/2021, 15:25:56] [dahua-alerts] 401 received and www-authenticate headers on 192.168.128.137, sending digest auth. Count: 1
[03/09/2021, 15:25:56] [dahua-alerts] Response recieved on host: 192.168.128.137: HTTP/1.1 200 OK
[03/09/2021, 15:25:56] [dahua-alerts] Could not parse event data: HTTP/1.1 200 OK
magic7s commented 3 years ago

Can you chmod a+x dist/* and commit that? Can I use a symlink to link /usr/local/lib/node_modules/homebridge-dahua-alerts/dist to /home/pi/homebridge-dahua-alerts/dist do you think that would work?

kushagharahi commented 3 years ago

I was creeping on your ffmpeg issue for a working config and saw you have an amcrest camera. Could you check out this comment and see if you can recreate? https://github.com/home-assistant/core/issues/33875#issuecomment-614904198

kushagharahi commented 3 years ago

Can you chmod a+x dist/* and commit that?

I can not, git status shows no changes. I think file permissions are not saved in git. As far as the symlink goes I'm not too sure. I personally copy over dist manually, so I am definitely curious if you come up with a solution. You have to restart homebridge anyhow 🤷

kushagharahi commented 3 years ago

Could you check if your camera firmware is up to date?

kushagharahi commented 3 years ago

It is so strange that it seems to work momentarily then go on a bad request loop

magic7s commented 3 years ago

I was creeping on your ffmpeg issue for a working config and saw you have an amcrest camera. Could you check out this comment and see if you can recreate? home-assistant/core#33875 (comment)

Yes, It's an Amcrest brand with older firmware, but funny thing is I tried homeassistant first and my camera's worked flawlessly, motion detection and all. I didn't love homeassistant and moved to homebridge. The ffmpeg plugin was not as nice as the amcrest one in homeassistant. I found your plugin and it works great. The motion detection works just fine. I'm getting doorbell notifications. It's just the scrolling errors in the log (that don't stop). As you can see we are getting the 200s and proper alerts from the stream connection. The issue you linked seems to state that they could not get stream to work and wanted to fall back to polling.

The firmware is the latest released by Amcrest. ~2017

It is so strange that it seems to work momentarily then go on a bad request loop

I agree, it's working, but the errors. My theory is that one connection is established and subsequent are rejected. I'm going to try and test that theory...

kushagharahi commented 3 years ago

Could you test changing [VideoMotion] to [All] also check VideoMotion (without brackets) to see if that makes any difference?

kushagharahi commented 3 years ago

When you set it up on home assistant do you remember which one of these options you chose? image

magic7s commented 3 years ago

I found something interesting. I disabled the plugin and did a clean reboot of one of the cameras. Then issued the curl commend curl -v -s --digest -u admin:password 'http://192.168.128.123/cgi-bin/eventManager.cgi?action=attach&codes=[VideoMotion]' and for the first ~25 connections, it worked fine (notice the 401 at the top though). Then after about 25 connections open, I am receiving 400 errors. So my theory is that the plugin is opening the connection and receiving the streamed alerts but then continues to try and open the connection multiple times until "max-sessions" is reached and the camera starts to reject new connections. Meanwhile the working stream is feeding alerts back to homebridge.

*   Trying 192.168.128.123...
* TCP_NODELAY set
* Connected to 192.168.128.123 (192.168.128.123) port 80 (#0)
* Server auth using Digest with user 'admin'
> GET /cgi-bin/eventManager.cgi?action=attach&codes=[VideoMotion] HTTP/1.1
> Host: 192.168.128.123
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 401 Unauthorized
< WWW-Authenticate: Digest realm="Login to AMC018NP69LM4VM2VY",qop="auth",nonce="1083253606",opaque="720000000000000000000007a9"
< Connection: close
< CONTENT-LENGTH: 0
<
* Closing connection 0
* Issue another request to this URL: 'http://192.168.128.123/cgi-bin/eventManager.cgi?action=attach&codes=[VideoMotion]'
* Hostname 192.168.128.123 was found in DNS cache
*   Trying 192.168.128.123...
* TCP_NODELAY set
* Connected to 192.168.128.123 (192.168.128.123) port 80 (#1)
* Server auth using Digest with user 'admin'
> GET /cgi-bin/eventManager.cgi?action=attach&codes=[VideoMotion] HTTP/1.1
> Host: 192.168.128.123
> Authorization: Digest username="admin", realm="Login to AMC018NP69LM4VM2VY", nonce="1083253606", uri="/cgi-bin/eventManager.cgi?action=attach&codes=[VideoMotion]", cnonce="MTU4ZDQxNZZZZZZZZZZZZZZZZZZZZZZZZNzI=", nc=00000001, qop=auth, response="83240000000000000000000747d3", opaque="7283d200000000000000000000657a9"
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Cache-Control: no-cache
< Pragma: no-cache
< Expires: Thu, 01 Dec 2099 16:00:00 GMT
< Connection: Keep-Alive
< Content-Type: multipart/x-mixed-replace; boundary=myboundary
* no chunk, no close, no size. Assume close to signal end
<
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Expires: Thu, 01 Dec 2099 16:00:00 GMT
Connection: Keep-Alive
Content-Type: multipart/x-mixed-replace; boundary=myboundary

After 25'ish connections

*   Trying 192.168.128.123...
* TCP_NODELAY set
* Connected to 192.168.128.123 (192.168.128.123) port 80 (#0)
* Server auth using Digest with user 'admin'
> GET /cgi-bin/eventManager.cgi?action=attach&codes=[VideoMotion] HTTP/1.1
> Host: 192.168.128.123
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 401 Unauthorized
< WWW-Authenticate: Digest realm="Login to AMC018NP69LM4VM2VY",qop="auth",nonce="1094214530",opaque="7283d244621e09f2f06e6e79ca5ccda284f657a9"
< Connection: close
< CONTENT-LENGTH: 0
<
* Closing connection 0
* Issue another request to this URL: 'http://192.168.128.123/cgi-bin/eventManager.cgi?action=attach&codes=[VideoMotion]'
* Hostname 192.168.128.123 was found in DNS cache
*   Trying 192.168.128.123...
* TCP_NODELAY set
* Connected to 192.168.128.123 (192.168.128.123) port 80 (#1)
* Server auth using Digest with user 'admin'
> GET /cgi-bin/eventManager.cgi?action=attach&codes=[VideoMotion] HTTP/1.1
> Host: 192.168.128.123
> Authorization: Digest username="admin", realm="Login to AMC018NP69LM4VM2VY", nonce="1094214530", uri="/cgi-bin/eventManager.cgi?action=attach&codes=[VideoMotion]", cnonce="N2JmZDQzNTZZZZZZZZZZZZZFmYWIxOWM=", nc=00000001, qop=auth, response="7720921e000000000d76f1", opaque="7283d244621000000000000084f657a9"
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 400 Bad Request
< CONNECTION: close
< CONTENT-LENGTH: 0
<
* Closing connection 1
magic7s commented 3 years ago
amcrest:
  - host: 192.168.128.123
    name: Front Door
    username: admin
    password: !secret amcrest_password
    binary_sensors:
      - motion_detected
      - crossline_detected
      - online
    sensors:
      - sdcard

FYI - I removed crossline as I was not using it.

magic7s commented 3 years ago

notice the 401 at the top though

The 401 appears to be normal https://stackoverflow.com/a/46802230

kushagharahi commented 3 years ago

Theoretically this is how the plugin works:

I don't how to validate that this plugin has a live socket (good) connection running and trying to reconnect over and over again. I don't want to disagree with you without hard proof. Personally, I think that this plugin is working intermittently for you, for example, the last log you posted shows it working intermittently

kushagharahi commented 3 years ago

I think the fix is to get keep alive strings working, so that when there's a good connection it keeps it alive as long as possible, instead of 30s of idle time, but there are issues with node (see: https://github.com/kushagharahi/homebridge-dahua-alerts/issues/14#issuecomment-835645808)

Fixing this would fix the other open issue too.

kushagharahi commented 3 years ago

I went ahead and commented out this reconnection: https://github.com/kushagharahi/homebridge-dahua-alerts/blob/master/src/dahua.ts#L89 and tried to trigger motion alerts after a timeout, and was unsuccessful. So I don't think the problem is with a long running socket connection

magic7s commented 3 years ago

I just did a clean reboot of both cameras and restarted HB and no errors for a while, now the errors are starting to show up. It could be a camera bug that doesn't timeout the connections fast enough. But I still think the plugin is filling up to max connections (about 25). So I see no errors for the first 15 - 20 minutes after the camera reboot but then they come back.

My original ask was to move the error to a debug so I don't have to watch it fill my logs. Still if there is a way to hold the connection open (and not open a new one) that would be the best solution.

I really appreciate all the work you have done on this plugin BTW. It's working great for my needs.

kushagharahi commented 3 years ago

My original ask was to move the error to a debug so I don't have to watch it fill my logs.

Unfortunately this is not something I'm willing to merge upstream, if you'd like you can go into the dist folder into index.js and change this line: this.log.error(`${data.error} (for more info enable debug logging)`); from error to debug

That error needs to exist so when people have issues with the plugin, it's readily apparent there's an error instead of silently failing

Until I lose your assistance I am going to continue trying to debug this issue. I'm working on finding a potential solution to keep the connection alive for more than 30s of idle time while still verifying the connection is good. I appreciate your help with how much you've been willing to debug this issue. Without users like you, I wouldn't be able to try and fix issues with the plugin!

magic7s commented 3 years ago

Understood.

I’m happy to help. Tell me when to git pull and I’ll test. Do you agree with my theory that one connection is kept open and providing the notifications while subsequent connections are created every 30 seconds until the max number of connections are reached by the camera and rejected with a 400 error.

Also 401 authentication error is a valid part of a new flow.

On Sep 3, 2021, at 7:00 PM, Kusha Gharahi @.***> wrote:

 My original ask was to move the error to a debug so I don't have to watch it fill my logs.

Unfortunately this is not something I'm willing to merge upstream, if you'd like you can go into the dist folder into index.js and change this line: this.log.error(${data.error} (for more info enable debug logging)); from error to debug

That error needs to exist so when people have issues with the plugin, it's readily apparent there's an error instead of slightly failing

Until I lose your assistance I am going to continue trying to debug this issue. I'm working on finding a potential solution to keep the connection alive for more than 30s of idle time while still verifying the connection is good. I appreciate your help with how much you've been willing to debug this issue. Without users like you, I wouldn't be able to try and fix issues with the plugin!

— You are receiving this because you were mentioned. 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 3 years ago

Do you agree with my theory that one connection is kept open and providing the notifications while subsequent connections are created every 30 seconds until the max number of connections are reached by the camera and rejected with a 400 error.

I don't agree because if I comment out all of the reconnection lines, I can not reproduce continuing to receive motion alerts past the timeout. I can push this up for you to verify as well, if you think that makes sense

subsequent connections are created every 30 seconds until the max number of connections are reached by the camera and rejected with a 400 error.

I agree with this

Also 401 authentication error is a valid part of a new flow.

Agree, this is apart of the digest auth flow

I just pushed a new commit where I increased the timeout from 30s to 10min. It looks like my camera system closes the socket connection every 1min 41 seconds. (example below) Maybe this will help?

[9/3/2021, 9:19:11 PM] [dahua-alerts] Socket connection timed out or closed on host: 192.168.1.100 + false
[9/3/2021, 9:19:11 PM] [dahua-alerts] Reconnecting in 1s.
[9/3/2021, 9:20:52 PM] [dahua-alerts] Socket connection timed out or closed on host: 192.168.1.100 + false
[9/3/2021, 9:20:52 PM] [dahua-alerts] Reconnecting in 1s.