agsh / onvif

ONVIF node.js implementation
http://agsh.github.io/onvif/
MIT License
693 stars 236 forks source link

Discovering devices on External Public IP #159

Closed Asher978 closed 3 years ago

Asher978 commented 4 years ago

what is the best way to provide the External IP for the site where the cam is located. I have set port forwarding on that site allowing a direct connection to the camera once i hit that port.

new CAM ({ HOSTNAME: // i have tried the external ip but no luck })

Is there a diff method or way to instantiate this class with an external IP?

chriswiggins commented 4 years ago

Hi @Asher978 - what ports are you forwarding?

Just as a side note, port-forwarding IP cameras is quite a dangerous thing to do. Many many cameras end up getting hacked and used in botnets - so be careful!

Asher978 commented 4 years ago

@chriswiggins Yes, security is controlled via IP Whitelisting and only allowing certain IPs to get though the network. This is all implemented at the firewall for the External Network.

Since the port forwarding on the network allows to get a connection to the camera, how can I instantiate a new instance of new Cam()

chriswiggins commented 4 years ago

Just use the IP address of the external router IP? That should work if port 80 is opened correctly

Asher978 commented 4 years ago

Diff issue now? Actually two Issues.

1 -->

camera Dahua IP Fixed Dome Cam

const config = {
hostname: "XXX.XXX.XXX.XXX",
    username: "XXXXX",
    password: "XXXXX",
    port: "8001",
    path: "/onvif/device_service",
}
new Cam(config, err => {
 if(err) {
  console.error(":: CAM Init ERROR :::", err)
 // ^^^ i get Cannot read property `width` of undefined
 }
})

2 -->

camera Avigilon Intercom Cam

All works here. However the rtsp uri returns the local IP. I am guessing this is expected and I would have to substitute the local IP to the site's public IP myself?

chriswiggins commented 4 years ago

The dahua camera might be returning some weird responses that we need to consider. Can you print the raw XML output? The new cam callback can take a third parameter xml to debug that

On the 2nd camera, yes that is correct the camera will return its internal IP as it doesn't know about the NAT

Asher978 commented 4 years ago
(err, data, xml) => {
    if (err) {
       // i dont have access to xml here. ONLY error. Did i miss something?
    }
  },
kidhasmoxy commented 4 years ago

Getting the same issue. Looks like some Onvif cameras don't return resolution or rate control information in the initial call, especially newer ones. Same issue seen on the node-onvif library. Need to allow for empty set and getting that information from other calls.

chriswiggins commented 3 years ago

Closing this - if you'd like this to be fixed we'd love you to send in a PR. Thanks!