Programmatically access multiple Dahua NVR using P2P (No port forwarding/VPN)

coderain1

n3wb
Nov 22, 2021
1
1
India
Requirement: Access multiple Dahua NVRs camera streams using the P2P method. i.e without having to do DDNS/port forwarding/VPN on the NVRs network.

Dahua provides clients for Win/Mac/Mobile, but no command-line tool. There are other 3rd party tools available but all of them have RTSP URL as input requirement, which is not useful to us since we are given only the SN/user/pass.

To understand how the client does this, we installed SmartPSS on Mac and added the NVRs using the P2P method (SN/username/password) and did some analysis of packets using Wireshark:
  • SmartPSS communicates with www.easy4ip.com with the Serial Number to get the Relay agents (Using WSSE protocol)
  • SmartPSS then queries the relay agent to get the public IP of the camera and does the UDP hole punching
  • Once the hole punching is done, all further communication is done with the public IP of the camera using PTCP protocol
    • The underlying messages seem to be using the Dahua NetSDK available here

We are even ready to write a small script for this, but the Dahua NetSDK expects to connect to the 37777 (Digital Video Recorder) port, which unfortunately is not available to us.

P.S: Our end goal is to get images from the cameras at 1FPS. If this is possible using the clients already provided by Dahua please let us know. (Note: The login method should be P2P)
 
  • Like
Reactions: kontrol
...
P.S: Our end goal is to get images from the cameras at 1FPS. If this is possible using the clients already provided by Dahua please let us know. (Note: The login method should be P2P)
In SmartPSS Device Config, see if you can select a P2P NVR camera, go to Encode>Snapshot and set it up with 1/S interval. Then go to Storage and set up Schedule and HDD Manager>FTP.
If it all works, you would then get all your snapshots stored in a FTP server.