quatanium / python-onvif

ONVIF Client Implementation in Python
MIT License
474 stars 321 forks source link

Unknown error [Errno 111] Connection refused #60

Open JoshMB8 opened 6 years ago

JoshMB8 commented 6 years ago

Hi I am currently working on a project with some IP cameras that support ONVIF. I am able to connect to the cameras via web-browser and using a third-party app (VMS) with no problems.

However I am getting some connection errors when I try to access the cameras/ camera info using the terminal on a Raspberry Pi 3.

I believe I have all the correct libraries and dependencies installed, and I am using Python 2.7. The initial error message I get is this:

pi@raspberrypi:~ $ onvif-cli devicemgmt GetHostname --user 'admin' --password '' --host '192.168.1.10' --port 8899 --wsdl /usr/local/wsdl False: Unknown error: <urlopen error [Errno 111] Connection refused>

If I try and run the same cmd again I get a bit more detail:

pi@raspberrypi:~ $ onvif-cli devicemgmt GetHostname --user 'admin' --password '' --host '192.168.1.10' --port 8899 --wsdl /usr/local/wsdl Traceback (most recent call last): File "/usr/local/bin/onvif-cli", line 9, in load_entry_point('onvif==0.2.0', 'console_scripts', 'onvif-cli')() File "/usr/local/lib/python2.7/dist-packages/onvif/cli.py", line 160, in main cli.setup(args) File "/usr/local/lib/python2.7/dist-packages/onvif/cli.py", line 39, in setup args.wsdl, encrypt=args.encrypt) File "/usr/local/lib/python2.7/dist-packages/onvif/client.py", line 258, in init self.update_xaddrs() File "/usr/local/lib/python2.7/dist-packages/onvif/client.py", line 274, in update_xaddrs capabilities = self.devicemgmt.GetCapabilities({'Category': 'All'}) File "/usr/local/lib/python2.7/dist-packages/onvif/client.py", line 32, in wrapped raise ONVIFError(err) onvif.exceptions.ONVIFError: Unknown error: <urlopen error [Errno 111] Connection refused>

I have checked that I am using the correct port and path to the wsdl directory and this error has occured on multiple cameras (I have 14 and have tried several of them).

Has anyone else come across this problem and does anyone know a solution?

Thanks, Josh

nitinkamble commented 6 years ago

I am trying similar thing on different cameras and noticed the same issue. some models the python onvif library is able to work and some models it is not Looks like the camera's firmware's implmentation of onvif is not perfect, or the user credentials for connecting to camera are different.

nitinkamble commented 6 years ago

I also noticed that the camera reboots after such failed onvif connection request.

gusarg81 commented 6 years ago

Hi,

I have this problem too with a IPCAM Sricam SP017. Now, with another Foscam IPCAM I do not have this problem at all.

EDIT: I don't know if related, but maybe is because this particular IPCAM handles only UDP? For example, in Motioneye I had to set rtsp_uses_tcp off to make it work (otherwise it will not connect to the cam).

sergioaiello commented 5 years ago

Hi gusarg81, which port is rtsp using? I'm sure you already checked it, but it's just to confirm.

gusarg81 commented 5 years ago

@sergioaiello Hi, this IPCAM uses port 554 for rtsp.

gusarg81 commented 4 years ago

Hi, I am trying to use again this, and since my cam only uses UDP, how I do specify to use that protocol? Thanks.