quatanium / python-onvif

ONVIF Client Implementation in Python
MIT License
470 stars 312 forks source link

(401, u'Authentication required.') with basic and (400, u'BadRequest') for digest #45

Open P4in69 opened 7 years ago

P4in69 commented 7 years ago

I could connect to my onvif device with the ONVIF Device Manager , but i couldn't connect with the python modul. I already checked the time on webserver and PC. I also tried diffrent users.

When i activate basic authentication mode i'll get this Traceback: Traceback (most recent call last): File "C:/Users/IRMonitor/PycharmProjects/untitled/Onvif test.py", line 4, in <module> mycam = ONVIFCamera('192.168.1.100', '80', 'admin', 'admin') File "C:\Users\IRMonitor\AppData\Roaming\Python\Python27\site-packages\onvif\client.py", line 227, in __init__ self.update_xaddrs() File "C:\Users\IRMonitor\AppData\Roaming\Python\Python27\site-packages\onvif\client.py", line 237, in update_xaddrs services = self.devicemgmt.GetServices({'IncludeCapability': False}) File "C:\Users\IRMonitor\AppData\Roaming\Python\Python27\site-packages\onvif\client.py", line 31, in wrapped raise ONVIFError(err) onvif.exceptions.ONVIFError: Unknown error: (401, u'Authentication required.') When i activate digest authentication mode i'll get this traceback: Traceback (most recent call last): File "C:/Users/IRMonitor/PycharmProjects/untitled/Onvif test.py", line 4, in <module> mycam = ONVIFCamera('192.168.1.100', '80', 'admin', 'admin') File "C:\Users\IRMonitor\AppData\Roaming\Python\Python27\site-packages\onvif\client.py", line 227, in __init__ self.update_xaddrs() File "C:\Users\IRMonitor\AppData\Roaming\Python\Python27\site-packages\onvif\client.py", line 237, in update_xaddrs services = self.devicemgmt.GetServices({'IncludeCapability': False}) File "C:\Users\IRMonitor\AppData\Roaming\Python\Python27\site-packages\onvif\client.py", line 31, in wrapped raise ONVIFError(err) onvif.exceptions.ONVIFError: Unknown error: (400, u'BadRequest')

Can someone tell me why the authentication fails? Operating System: Windows 7 Pycharm Python 2.7

P4in69 commented 7 years ago

It seems to be that the Suds Libary have problems to create repr. Unable to get repr for suds.plugin.PluginContainer

Any Ideas?

FredericG-BE commented 7 years ago

I am facing the same issue; camera's working well with ONVIF Device Manager but the same exception in the ONIFCamera constructor...

P4in69 commented 7 years ago

I tried it now also on an Linux (Ubuntu) platform, same issue :(

P4in69 commented 7 years ago

I got it, the released Version is older than the Version on GitHub. Download Zip and install via cmd and pip.

FredericG-BE commented 7 years ago

Indeed, this fixes this particular issue. Thanks

jn0 commented 7 years ago

Fresh package just installed via pip fails to communicate with quite ugly message:

jno@jno-intra:~$ onvif-cli -v -u root -a PxxxD --host 172.17.16.101 --port 80 \
                                        --wsdl /usr/local/wsdl devicemgmt GetWsdlUrl
Traceback (most recent call last):
  File "/usr/local/bin/onvif-cli", line 11, in <module>
    sys.exit(main())
  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 227, in __init__
    self.update_xaddrs()
  File "/usr/local/lib/python2.7/dist-packages/onvif/client.py", line 237, in update_xaddrs
    services = self.devicemgmt.GetServices({'IncludeCapability': False})
  File "/usr/local/lib/python2.7/dist-packages/onvif/client.py", line 31, in wrapped
    raise ONVIFError(err)
onvif.exceptions.ONVIFError: Unknown error: (400, u'Bad Request')

The cam is in its place:

jno@jno-intra:~$ echo 'quit' | nc -v 172.17.16.101 21
Connection to 172.17.16.101 21 port [tcp/ftp] succeeded!
220 AXIS P1214-E Network Camera 5.40.12.1 (2013) ready.
221 Goodbye.

Where to look at?

jn0 commented 7 years ago

Even fresher install (git clone + build + install) does just the same. Screenshot of web browser window depicting ONVIF enablement:

screenshot on imgur

jn0 commented 7 years ago

change of encrypt=True to encrypt=False doesn't help too

jn0 commented 7 years ago

And, yes, the cam do have those .wsdl files and they are accessible:

jno@jno-intra:~$ curl -vvv http://172.17.16.101/wsdl/onvif/ptz.wsdl
*   Trying 172.17.16.101...
Connected to 172.17.16.101 (172.17.16.101) port 80 (#0)
> GET /wsdl/onvif/ptz.wsdl HTTP/1.1
> Host: 172.17.16.101
> User-Agent: curl/7.47.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Tue, 29 Nov 2016 15:14:56 GMT
< Accept-Ranges: bytes
< Connection: close
< Content-Length: 27255
< Last-Modified: Wed, 04 Apr 2012 08:39:02 GMT
< Content-Type: text/plain
< 
...27K bytes of XML...
jn0 commented 7 years ago

Oooops.

this cannot be used on AXIS camera

:(