sr99622 / libonvif

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

Auto Discovery and Camera Login #102

Open madroots opened 2 weeks ago

madroots commented 2 weeks ago

Discovery won't find anything. I have read through the other issues with this and understand that there are many things that might cause this. I added camera IP manually, and it finds the camera and asks for user and password but its not accepting it, asking for user and password over and over again. ONVIF user and password is 100% correct.

Its a Dahua IP camera.

sr99622 commented 2 weeks ago

Thank you for reaching out with this finding. It would appear that Dahua may have updated the camera software to improve compliance with the ONVIF login algorithm. This in turn may have triggered a bug in onvif-gui when manually adding a camera.

I believe the issue has been resolved and a new version of the program (2.2.9) is available. If you installed via pip, the command to update the program is

pip install --upgrade onvif-gui
sr99622 commented 2 weeks ago

@madroots

If you are not able to log into the Dahua camera, please let me know.

madroots commented 2 weeks ago

Thank you for your reply and update. It logins fine now after adding manually. However, the camera won't start. Gives this output:

2024-10-07 09:00:29.386 | DEBUG | gui.onvif.videotab:syncGUI:326 - The settings for aspect ratio 0.0 were not found for camera 192.168.10.105

Aspect ratio setting is indeed set to "UNKN" and won't allow changing it. Interesting.

sr99622 commented 2 weeks ago

Indeed an interesting result that could indicate different failure scenarios that may be in play. One possibility is that the authentication has actually failed, but this is not showing up in an error message. The reason I lean towards this possibility is that the first operation upon successful login is to poll the camera for configuration data. This operation will populate the Media, Image and Network tabs at the bottom of the camera panel. If these tabs are empty when the camera is highlighted in the list by clicking on it, that would be a piece of evidence in support of this theory. The message of aspect ratio 0.0 might result from the lack of resolution data from the camera which should have been returned from the poll.

There are some gotchas when working with Dahua that might contribute to this condition. The ONVIF interface is not enabled by default. If you are able to log onto the camera using the camera interface in a WEB BROWSER, there are some settings that are required for ONVIF login. At the top right of the interface should be a Setup Tab. For the camera that I have, there is then a selection on the left panel for Network->Port and then a secondary Tab ONVIF with a radio button Authentication On/Off, which needs to be On. There is also a System->Account selection with a Tab for Onvif User. There needs to be a user added to the account for Onvif to be enabled. In my case, the user name is admin and the group is admin. There is also a System->Safety selection and a tab for RTSP authentication, which for me is set to Digest.

A successful login will produce a log message similar to below. The data in the second line will only appear if there has been a succesful login.

2024-10-07 10:46:27.209 | DEBUG    | gui.panels.options.discover:btnAddCameraClicked:158 - Attempting to add camera manually using xaddrs: http://10.1.1.66:80/onvif/device_service
2024-10-07 10:46:27.581 | DEBUG    | gui.panels.camerapanel:getData:503 - Discovery completed for Camera: Dahua IPC-HDW4631C-A, Serial Number: 4B0013BPAABE264, Stream URI: rtsp://10.1.1.66:554/cam/realmonitor?channel=1&subtype=1&unicast=true&proto=Onvif, xaddrs: http://10.1.1.66:80/onvif/device_service

If these things are present and the Media tab is populated, there are other conditions in effect. If this is the case, some log messages may help shed light on the condition. You could try changing the profile to see if that had any effect.

Best Regards and thank you so much for your patience,

Stephen

sr99622 commented 2 weeks ago

I did some further research and found a potential cause for what is happening. There is an error in a configuration used for communicating with the camera that is in the Manual Add Camera code. The error involves the device service string in the onvif command which looks like an http post. There was a missing '\r' in the post command that possibly might cause a failure to communicate. I updated the program to fix this issue, since it should corrected regardless. It's worth a try if you are game.

If you installed via pip, use the command to get the new version 2.2.10

pip install --upgrade onvif-gui