ZoneMinder / pyzm

Python API, Log, Event Server and Memory wrapper for ZoneMinder
GNU General Public License v2.0
32 stars 21 forks source link

Infinite loop on gettimezone.json > Error 401 #24

Closed jerryzz closed 3 years ago

jerryzz commented 3 years ago

Event Server version

6.1.14

Hooks version (if you are using Object Detection)

app:6.1.14, pyzm:0.3.36

The version of ZoneMinder you are using:

1.34.23

What is the nature of your issue

Bug/question

Details

Got an 401 error calling api 'gettimezone.json ' > Infinite loop What do I wrong ?

Debug Logs (if applicable)

03/11/21 09:59:38 zmesdetect_m5[2666] DBG2 api.py:200 [Using new token API]
03/11/21 09:59:38 zmesdetect_m5[2666] DBG1 api.py:207 [Access token expires on:2021-03-11 11:59:38.160035 [7200s]]
03/11/21 09:59:38 zmesdetect_m5[2666] DBG3 api.py:134 [No need to relogin as access token still has 119.99905236666667 minutes remaining]
03/11/21 09:59:38 zmesdetect_m5[2691] DBG1 api.py:306 [HTTP error: 401 Client Error: Unauthorized for url: https://xxxx.xxxx.xxx/zm/api/host/login.json/host/gettimezone.json?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNjE1NDUzMTc3LCJleHAiOjE2MTU0NjAzNzcsInVzZXIiOiJldmVudCIsInR5cGUiOiJhY2Nlc3MifQ.u9QUthvpQTmDzfZl4wHssMH4DHtzIcKggOYJydSTEvc]
03/11/21 09:59:38 zmesdetect_m5[2666] DBG4 api.py:270 [make_request called with url=https://xxxx.xxxx.xxx/zm/api/host/login.json/host/gettimezone.json payload={} type=get query={'token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNjE1NDUzMTc4LCJleHAiOjE2MTU0NjAzNzgsInVzZXIiOiJldmVudCIsInR5cGUiOiJhY2Nlc3MifQ.rR39TAcjVBm7G5ZXvepz2fGABJ2vifNzXvsooQ0iWWI'}]
03/11/21 09:59:38 zmesdetect_m5[2691] DBG1 api.py:308 [Got 401 (Unauthorized) - retrying login once]
03/11/21 09:59:38 zmesdetect_m5[2691] DBG2 api.py:150 [Going to use refresh token as it still has 1438.6680266833332 minutes remaining]
03/11/21 09:59:38 zmesdetect_m5[2666] DBG1 api.py:306 [HTTP error: 401 Client Error: Unauthorized for url: https://xxxx.xxxx.xxx/zm/api/host/login.json/host/gettimezone.json?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNjE1NDUzMTc4LCJleHAiOjE2MTU0NjAzNzgsInVzZXIiOiJldmVudCIsInR5cGUiOiJhY2Nlc3MifQ.rR39TAcjVBm7G5ZXvepz2fGABJ2vifNzXvsooQ0iWWI]
03/11/21 09:59:38 zmesdetect_m5[2691] DBG1 api.py:166 [Using token for login [eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNjE1NDUzMDk4LCJleHAiOjE2MTU1Mzk0OTgsInVzZXIiOiJldmVudCIsInR5cGUiOiJyZWZyZXNoIn0.GMjlKgWRWKH_FgiQAV_5I3z_7ye8CaKGaT83jAFyPzY]]
03/11/21 09:59:38 zmesdetect_m5[2666] DBG1 api.py:308 [Got 401 (Unauthorized) - retrying login once]
03/11/21 09:59:38 zmesdetect_m5[2691] DBG2 api.py:200 [Using new token API]
03/11/21 09:59:38 zmesdetect_m5[2666] DBG2 api.py:150 [Going to use refresh token as it still has 1438.5858064833333 minutes remaining]
03/11/21 09:59:38 zmesdetect_m5[2691] DBG1 api.py:207 [Access token expires on:2021-03-11 11:59:38.511812 [7200s]]
03/11/21 09:59:38 zmesdetect_m5[2666] DBG1 api.py:166 [Using token for login [eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNjE1NDUzMDkzLCJleHAiOjE2MTU1Mzk0OTMsInVzZXIiOiJldmVudCIsInR5cGUiOiJyZWZyZXNoIn0.B72Q7C0djkyEBBcXN_eMDaR_AHPnhUTfSoewdE8RBp8]]
03/11/21 09:59:38 zmesdetect_m5[2691] DBG3 api.py:134 [No need to relogin as access token still has 119.99908488333334 minutes remaining]
03/11/21 09:59:38 zmesdetect_m5[2666] DBG2 api.py:200 [Using new token API]
03/11/21 09:59:38 zmesdetect_m5[2691] DBG4 api.py:270 [make_request called with url=https://xxxx.xxxx.xxx/zm/api/host/login.json/host/gettimezone.json payload={} type=get query={'token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNjE1NDUzMTc4LCJleHAiOjE2MTU0NjAzNzgsInVzZXIiOiJldmVudCIsInR5cGUiOiJhY2Nlc3MifQ.rR39TAcjVBm7G5ZXvepz2fGABJ2vifNzXvsooQ0iWWI'}]
03/11/21 09:59:38 zmesdetect_m5[2666] DBG1 api.py:207 [Access token expires on:2021-03-11 11:59:38.699222 [7200s]]
03/11/21 09:59:38 zmesdetect_m5[2666] DBG3 api.py:134 [No need to relogin as access token still has 119.99904713333333 minutes remaining]
03/11/21 09:59:38 zmesdetect_m5[2691] DBG1 api.py:306 [HTTP error: 401 Client Error: Unauthorized for url: https://xxxx.xxxx.xxx/zm/api/host/login.json/host/gettimezone.json?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNjE1NDUzMTc4LCJleHAiOjE2MTU0NjAzNzgsInVzZXIiOiJldmVudCIsInR5cGUiOiJhY2Nlc3MifQ.rR39TAcjVBm7G5ZXvepz2fGABJ2vifNzXvsooQ0iWWI]
03/11/21 09:59:38 zmesdetect_m5[2666] DBG4 api.py:270 [make_request called with url=https://xxxx.xxxx.xxx/zm/api/host/login.json/host/gettimezone.json payload={} type=get query={'token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNjE1NDUzMTc4LCJleHAiOjE2MTU0NjAzNzgsInVzZXIiOiJldmVudCIsInR5cGUiOiJhY2Nlc3MifQ.rR39TAcjVBm7G5ZXvepz2fGABJ2vifNzXvsooQ0iWWI'}]
03/11/21 09:59:38 zmesdetect_m5[2691] DBG1 api.py:308 [Got 401 (Unauthorized) - retrying login once]
03/11/21 09:59:39 zmesdetect_m5[2691] DBG2 api.py:150 [Going to use refresh token as it still has 1438.6571430166666 minutes remaining]
03/11/21 09:59:39 zmesdetect_m5[2666] DBG1 api.py:306 [HTTP error: 401 Client Error: Unauthorized for url: https://xxxx.xxxx.xxx/zm/api/host/login.json/host/gettimezone.json?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNjE1NDUzMTc4LCJleHAiOjE2MTU0NjAzNzgsInVzZXIiOiJldmVudCIsInR5cGUiOiJhY2Nlc3MifQ.rR39TAcjVBm7G5ZXvepz2fGABJ2vifNzXvsooQ0iWWI]
03/11/21 09:59:39 zmesdetect_m5[2691] DBG1 api.py:166 [Using token for login [eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNjE1NDUzMDk4LCJleHAiOjE2MTU1Mzk0OTgsInVzZXIiOiJldmVudCIsInR5cGUiOiJyZWZyZXNoIn0.GMjlKgWRWKH_FgiQAV_5I3z_7ye8CaKGaT83jAFyPzY]]

Thanks!

jerryzz commented 3 years ago

Here the beginning of the debug log

03/11/21 11:51:17 zmesdetect_m5[2459] INF ZMLog.py:223 [Setting up signal handler for logs]                                                                                                                                                xxxx.xxxx.xxx
03/11/21 11:51:17 zmesdetect_m5[2459] INF zm_detect.py:280 [---------| app:6.1.14, pyzm:0.3.36, ES:6.1.14 , OpenCV:4.3.0-dev|------------]                                                                                                  
03/11/21 11:51:17 zmesdetect_m5[2459] DBG1 utils.py:406 [secret filename: /etc/zm/secrets.ini]                                                                                                                                              
03/11/21 11:51:17 zmesdetect_m5[2459] DBG2 utils.py:379 [Secret token found in config: !ZM_PORTAL]                                                                                                                                          
03/11/21 11:51:17 zmesdetect_m5[2459] DBG2 utils.py:379 [Secret token found in config: !ZM_USER]                                                                                                                                            
03/11/21 11:51:17 zmesdetect_m5[2459] DBG2 utils.py:379 [Secret token found in config: !ZM_PASSWORD]                                                                                                                                        
03/11/21 11:51:17 zmesdetect_m5[2459] DBG2 utils.py:379 [Secret token found in config: !ZM_API_PORTAL]                                                                                                                                      
03/11/21 11:51:17 zmesdetect_m5[2459] DBG2 utils.py:379 [Secret token found in config: !ML_HOST]                                                                                                                                            
03/11/21 11:51:17 zmesdetect_m5[2459] DBG2 utils.py:379 [Secret token found in config: !ML_USER]                                                                                                                                            
03/11/21 11:51:17 zmesdetect_m5[2459] DBG2 utils.py:379 [Secret token found in config: !ML_PASSWORD]                                                                                                                                        
03/11/21 11:51:17 zmesdetect_m5[2459] DBG1 utils.py:441 [allowing self-signed certs to work...]                                                                                                                                             
03/11/21 11:51:17 zmesdetect_m5[2459] DBG4 utils.py:451 [Now checking for monitor overrides]                                                                                                                                                
03/11/21 11:51:17 zmesdetect_m5[2459] DBG4 utils.py:514 [Finally, doing parameter substitution]                                                                                                                                             
03/11/21 11:51:17 zmesdetect_m5[2459] INF zm_detect.py:309 [Importing remote shim classes for Object/Face]                                                                                                                                  
03/11/21 11:51:18 zmesdetect_m5[2459] INF zm_detect.py:328 [Connecting with ZM APIs]                                                                                                                                                        
03/11/21 11:51:18 zmesdetect_m5[2459] DBG2 api.py:69 [API SSL certificate check has been disbled]                                                                                                                                           
03/11/21 11:51:18 zmesdetect_m5[2459] DBG1 api.py:171 [using username/password for login]                                                                                                                                                   
03/11/21 11:51:18 zmesdetect_m5[2459] DBG2 api.py:200 [Using new token API]                                                                                                                                                                 
03/11/21 11:51:18 zmesdetect_m5[2459] DBG1 api.py:207 [Access token expires on:2021-03-11 13:51:18.332891 [7200s]]                                                                                                                          
03/11/21 11:51:18 zmesdetect_m5[2459] DBG1 api.py:211 [Refresh token expires on:2021-03-12 11:51:18.333521 [86400s]]                                                                                                                        
03/11/21 11:51:18 zmesdetect_m5[2459] DBG3 api.py:134 [No need to relogin as access token still has 119.99997955 minutes remaining]                                                                                                         
03/11/21 11:51:18 zmesdetect_m5[2459] DBG4 api.py:270 [make_request called with url=https://xxxx.xxxx.xxx/zm/api/host/login.json/host/gettimezone.json payload={} type=get query={'token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiO
03/11/21 11:51:18 zmesdetect_m5[2459] DBG1 api.py:306 [HTTP error: 401 Client Error: Unauthorized for url: https://xxxx.xxxx.xxx/zm/api/host/login.json/host/gettimezone.json?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lT
03/11/21 11:51:18 zmesdetect_m5[2459] DBG1 api.py:308 [Got 401 (Unauthorized) - retrying login once]                                                                                                                                        
03/11/21 11:51:18 zmesdetect_m5[2459] DBG2 api.py:150 [Going to use refresh token as it still has 1439.9988944166666 minutes remaining]                                                                                                     
03/11/21 11:51:18 zmesdetect_m5[2459] DBG1 api.py:166 [Using token for login [eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNjE1NDU5ODc4LCJleHAiOjE2MTU1NDYyNzgsInVzZXIiOiJldmVudCIsInR5cGUiOiJyZWZyZXNoIn0.v_I26
03/11/21 11:51:18 zmesdetect_m5[2459] DBG2 api.py:200 [Using new token API] 
03/11/21 11:51:18 zmesdetect_m5[2459] DBG1 api.py:207 [Access token expires on:2021-03-11 13:51:18.408356 [7200s]]                                                                                                                          
03/11/21 11:51:18 zmesdetect_m5[2459] DBG3 api.py:134 [No need to relogin as access token still has 119.99998609999999 minutes remaining]                                                                                                   
03/11/21 11:51:18 zmesdetect_m5[2459] DBG4 api.py:270 [make_request called with url=https://xxxx.xxxx.xxx/zm/api/host/login.json/host/gettimezone.json payload={} type=get query={'token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiO
03/11/21 11:51:18 zmesdetect_m5[2459] DBG1 api.py:306 [HTTP error: 401 Client Error: Unauthorized for url: https://xxxx.xxxx.xxx/zm/api/host/login.json/host/gettimezone.json?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lT
03/11/21 11:51:18 zmesdetect_m5[2459] DBG1 api.py:308 [Got 401 (Unauthorized) - retrying login once]  
jerryzz commented 3 years ago

Seems I'm tired ... I used the 'secrets.ini' file for the old version, which have "/zm/api/host/login.json" path in the ZM_API_PORTAL variable, instead "/zm/api"

pliablepixels commented 3 years ago

Should not be an infinite loop though. Re-opening till I fix.