FalkTannhaeuser / python-onvif-zeep

ONVIF Client Implementation in Python 2+3 (using https://github.com/mvantellingen/python-zeep instead of suds as SOAP client)
MIT License
420 stars 137 forks source link

onvif.exceptions.ONVIFError: Unknown error: (401, 'Unauthorized') #76

Open htaufik opened 3 years ago

htaufik commented 3 years ago

Hello, I'm getting some problems when running the example_control_onvif. When i running the code it says error like this Traceback (most recent call last): File "/home/otka/.local/lib/python3.6/site-packages/suds/transport/http.py", line 78, in send fp = self.u2open(u2request) File "/home/otka/.local/lib/python3.6/site-packages/suds/transport/http.py", line 119, in u2open return url.open(u2request, timeout=tm) File "/usr/lib/python3.6/urllib/request.py", line 532, in open response = meth(req, response) File "/usr/lib/python3.6/urllib/request.py", line 642, in http_response 'http', request, response, code, msg, hdrs) File "/usr/lib/python3.6/urllib/request.py", line 570, in error return self._call_chain(args) File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain result = func(args) File "/usr/lib/python3.6/urllib/request.py", line 650, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 401: Unauthorized

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/otka/.local/lib/python3.6/site-packages/suds/client.py", line 652, in send reply = transport.send(request) File "/home/otka/.local/lib/python3.6/site-packages/suds/transport/http.py", line 178, in send return HttpTransport.send(self, request) File "/home/otka/.local/lib/python3.6/site-packages/suds/transport/http.py", line 86, in send raise TransportError(e.msg, e.code, e.fp) suds.transport.TransportError: Unauthorized

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/otka/.local/lib/python3.6/site-packages/onvif/client.py", line 34, in wrapped return func(*args, kwargs) File "/home/otka/.local/lib/python3.6/site-packages/onvif/client.py", line 201, in wrapped return call(params, callback) File "/home/otka/.local/lib/python3.6/site-packages/onvif/client.py", line 191, in call ret = func(params) File "/home/otka/.local/lib/python3.6/site-packages/suds/client.py", line 559, in call return client.invoke(args, kwargs) File "/home/otka/.local/lib/python3.6/site-packages/suds/client.py", line 618, in invoke result = self.send(soapenv) File "/home/otka/.local/lib/python3.6/site-packages/suds/client.py", line 664, in send result = self.failed(binding, e) File "/home/otka/.local/lib/python3.6/site-packages/suds/client.py", line 726, in failed raise Exception((status, reason)) Exception: (401, 'Unauthorized')

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/otka/venv1/sensecam-control-master/example_control_onvif.py", line 70, in X.camera_start() File "/home/otka/venv1/sensecam-control-master/sensecam_control/onvif_control.py", line 43, in camera_start media_profile = media.GetProfiles()[0] File "/home/otka/.local/lib/python3.6/site-packages/onvif/client.py", line 36, in wrapped raise ONVIFError(err) onvif.exceptions.ONVIFError: Unknown error: (401, 'Unauthorized')

I'm using rtsp, anyone can help me? Thanks before

gene-code commented 3 years ago

My guess is Unauthorized means you did not supply the correct onvif username/password. These are different than the camera admin login/password. You need to login to your camera and create onvif user. and then use that user's credentials to initiate an onvifcamera object.