Closed pedromoraesh closed 3 years ago
Could you post debug logs when this occurs? You've only posted the exception traceback.
@pliablepixels
[INFO] Using simple log output (default)
[DEBUG 1] Warning, SSL certificate check has been disbled
[DEBUG 1] using username/password for login
[DEBUG 1] Using new token API
[DEBUG 1] Refresh token expires on:2020-08-10 21:32:03.151076 [86400s]
[DEBUG 1] make_request called with url=http://192.168.15.5/zm/api/host/gettimezone.json payload={} type=get query={'token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNTk3$
[INFO] Using simple log output (default)
[DEBUG 1] Retrieving monitors via API
[DEBUG 1] make_request called with url=http://192.168.15.5/zm/api/monitors.json payload={} type=get query={'token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNTk3MDIzMTIz$
[INFO] Using simple log output (default)
[DEBUG 1] Retrieving config via API
[DEBUG 1] make_request called with url=http://192.168.15.5/zm/api/configs.json payload={} type=get query={'token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNTk3MDIzMTIzL$
[Every 1 day at 21:35:00 do start_video_recording() (last run: [never], next run: 2020-08-09 21:35:00), Every 1 day at 08:00:00 do createJob() (last run: [never], next run: 2020-08-10 08:00:00), Every 1 $
Start Recording Videos 08/09/2020 - 21:35:00
[DEBUG 1] make_request called with url=http://192.168.15.5/zm/api/monitors/1.json payload={'Monitor[Function]': 'Record', 'Monitor[Enabled]': '1'} type=post query={'token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJI$
Stopping Videos 08/09/2020 - 23:40:00
[DEBUG 1] make_request called with url=http://192.168.15.5zm/api/monitors/1.json payload={'Monitor[Function]': 'None', 'Monitor[Enabled]': '0'} type=post query={'token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUz$
[DEBUG 1] Got API access error: 401 Client Error: Unauthorized for url: http://192.168.15.5/zm/api/monitors/1.json?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNTk3MDIz$
[DEBUG 1] Retrying login once
[DEBUG 1] Going to use refresh token as it still has 1312.0474727666667 minutes remaining
[DEBUG 1] Using token for login [eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNTk3MDIzMTIzLCJleHAiOjE1OTcxMDk1MjMsInVzZXIiOiJmbG93aXgiLCJ0eXBlIjoicmVmcmVzaCJ9.KXEaVciXR4sKL86a$
[DEBUG 1] Using new token API
Traceback (most recent call last):
File "/home/myuser/.local/lib/python3.6/site-packages/pyzm/api.py", line 252, in _make_request
r.raise_for_status()
File "/home/myuser/.local/lib/python3.6/site-packages/requests/models.py", line 941, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: http://192.168.15.5/zm/api/monitors/1.json?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNTk3MDIzM$
Confirmed, will see what is going on.
I've published an updated version of pyzm. Please try it out - seems to work for me after 1-2 hour gaps
Trying right know. Did you update the pip version ? Or from source?
Putting script to run with scheduler for 8 hours.
Yes, the package is updated
@pliablepixels 3 days of running, no problems for now!
sounds good. I suppose we can close for now. If it reappears, we can reopen.
Hello Guys,
I have a routine coded with scheduler and twice a day i Start 7 AM and Stop 10 AM my monitors using:
m.set_parameter({'enabled': False, 'function': "None"})
Then i getting the error:
In a space of 1 hour, the error doesn't occur. In order to reproduce the error i used a space of 3 hours between turn ON and OFF the monitor!
Seems like token is expiring and can't perform calls to API, because before this error Unauthorized operation exception occurs.
I did the operation with 1 Hour manually in python3 terminal and everything worked, like images below. I think is something with the Token Refresh Operation!
AUTH_RELAY is set to hashed A valid AUTH_HASH_SECRET is provided (not empty) AUTH_HASH_IPS is disabled OPT_USE_APIS is enabled
I found something my be related to this ISSUE: https://github.com/ZoneMinder/zoneminder/issues/2866
ZM Version 1.34.16