sr99622 / libonvif

Onvif library with GUI implementation and built in YOLOX
GNU Lesser General Public License v2.1
160 stars 41 forks source link

Unable to connect - support different ports? Empty password? #63

Closed zorander934 closed 1 year ago

zorander934 commented 1 year ago

Hi!

I was happy to find this tool, but unfortunately I haven't been able to connect to my camera. (I assume there will be some kind of confirmation when it's connected?)

I'm using Debian without GUI.

My camera is on another network, but I can ping the camera and I can access the web interface and the onvif interface with curl.

One problem might be that my camera uses port 8899 for the onvif interface.

My camera's onvif interface is: 192.168.1.10:8899/onvif/device_service

It would be good if it was possible to set the port as an argument. Maybe "-P port" or "ip-address[:port]" ([ ] as in optional).

From what I have read, not all cameras use "/onvif/device_service", so it would be good if that also could be set. Maybe: "onvif-util -u user -p password ip-address[:port][path]" (path always begins with "/")

However, I tried to redirect all tcp traffic to my camera to port 8899 using iptables (I confirmed with curl that it worked), but I could still not connect to the camera with onvif-util, so maybe the port wasn't the only problem.

What if the password is empty? (0 characters string, "".) Is it enough to omit -p? Does it work to use e.g. "-p """ or "-p -"? If not, maybe there should be an argument for empty password.

Best regards!

sr99622 commented 1 year ago

Thank you so much for reaching out.

The onvif-util has not been tested for external networks, although this is something that should be added to the project.

Something to note is that the program depends upon the discovery function to establish communication with the cameras. The mechanism for this is a UDP broadcast. The host computer sends out a broadcast packet on port 3702 and devices respond to that port with their connection requirements. If the camera is able to receive the broadcast and reply successfully, the program should theoretically be able to communicate with whatever port and protocol the camera specifies.

If the command onvif-util -a gets a response from the camera, its IP address should appear in the response, and can be used with further commands for configuration. If there is no response, onvif-util will not be able to communicate with the camera.

Broadcasting to external networks requires some configuration which I can't recall right now as it's been a few years since I worked on that sort of thing, but it may require opening the broadcast port (3702) on the router. There may need to be a TTL setting on the packet as well. I've heard that onvifviewer is able to do these things, but I don't have first hand experience with that.

I hope this information is useful, I will be setting up some development for the external network connections when time permits and hopefully getting this to work, as it seems to be a very useful feature.

Best Regards,

Stephen