lichess-bot-devs / lichess-bot

A bridge between Lichess bots and chess engines
GNU Affero General Public License v3.0
745 stars 440 forks source link

Matchmaking error #728

Closed FatFritz2 closed 1 year ago

FatFritz2 commented 1 year ago
2023-06-01T23:52:07.302732+00:00 app[worker.1]:                     WARNING  Endpoint /api/challenge/{} is rate   lichess.py:145
2023-06-01T23:52:07.302734+00:00 app[worker.1]:                              limited. Waiting 60 seconds until                  
2023-06-01T23:52:07.302734+00:00 app[worker.1]:                              next request.                                      
2023-06-01T23:52:07.313819+00:00 app[worker.1]:                     ERROR    Could not create challenge        matchmaking.py:68
2023-06-01T23:52:07.313819+00:00 app[worker.1]:                              Traceback (most recent call                        
2023-06-01T23:52:07.313820+00:00 app[worker.1]:                              last):                                             
2023-06-01T23:52:07.313820+00:00 app[worker.1]:                                File                                             
2023-06-01T23:52:07.313820+00:00 app[worker.1]:                              "/usr/local/lib/python3.9/dist-pa                  
2023-06-01T23:52:07.313821+00:00 app[worker.1]:                              ckages/requests/models.py", line                   
2023-06-01T23:52:07.313821+00:00 app[worker.1]:                              971, in json                                       
2023-06-01T23:52:07.313821+00:00 app[worker.1]:                                  return                                         
2023-06-01T23:52:07.313821+00:00 app[worker.1]:                              complexjson.loads(self.text,                       
2023-06-01T23:52:07.313822+00:00 app[worker.1]:                              **kwargs)                                          
2023-06-01T23:52:07.313822+00:00 app[worker.1]:                                File                                             
2023-06-01T23:52:07.313822+00:00 app[worker.1]:                              "/usr/lib/python3.9/json/__init__                  
2023-06-01T23:52:07.313822+00:00 app[worker.1]:                              .py", line 346, in loads                           
2023-06-01T23:52:07.313823+00:00 app[worker.1]:                                  return                                         
2023-06-01T23:52:07.313823+00:00 app[worker.1]:                              _default_decoder.decode(s)                         
2023-06-01T23:52:07.313823+00:00 app[worker.1]:                                File                                             
2023-06-01T23:52:07.313823+00:00 app[worker.1]:                              "/usr/lib/python3.9/json/decoder.                  
2023-06-01T23:52:07.313823+00:00 app[worker.1]:                              py", line 337, in decode                           
2023-06-01T23:52:07.313824+00:00 app[worker.1]:                                  obj, end = self.raw_decode(s,                  
2023-06-01T23:52:07.313824+00:00 app[worker.1]:                              idx=_w(s, 0).end())                                
2023-06-01T23:52:07.313824+00:00 app[worker.1]:                                File                                             
2023-06-01T23:52:07.313824+00:00 app[worker.1]:                              "/usr/lib/python3.9/json/decoder.                  
2023-06-01T23:52:07.313824+00:00 app[worker.1]:                              py", line 355, in raw_decode                       
2023-06-01T23:52:07.313824+00:00 app[worker.1]:                                  raise                                          
2023-06-01T23:52:07.313825+00:00 app[worker.1]:                              JSONDecodeError("Expecting                         
2023-06-01T23:52:07.313825+00:00 app[worker.1]:                              value", s, err.value) from None                    
2023-06-01T23:52:07.313825+00:00 app[worker.1]:                              json.decoder.JSONDecodeError:                      
2023-06-01T23:52:07.313825+00:00 app[worker.1]:                              Expecting value: line 1 column 1                   
2023-06-01T23:52:07.313825+00:00 app[worker.1]:                              (char 0)                                           
2023-06-01T23:52:07.313825+00:00 app[worker.1]:                                                                                 
2023-06-01T23:52:07.313826+00:00 app[worker.1]:                              During handling of the above                       
2023-06-01T23:52:07.313826+00:00 app[worker.1]:                              exception, another exception                       
2023-06-01T23:52:07.313826+00:00 app[worker.1]:                              occurred:                                          
2023-06-01T23:52:07.313827+00:00 app[worker.1]:                                                                                 
2023-06-01T23:52:07.313827+00:00 app[worker.1]:                              Traceback (most recent call                        
2023-06-01T23:52:07.313827+00:00 app[worker.1]:                              last):                                             
2023-06-01T23:52:07.313827+00:00 app[worker.1]:                                File "/matchmaking.py", line                     
2023-06-01T23:52:07.313827+00:00 app[worker.1]:                              61, in create_challenge                            
2023-06-01T23:52:07.313827+00:00 app[worker.1]:                                  response =                                     
2023-06-01T23:52:07.313828+00:00 app[worker.1]:                              self.li.challenge(username,                        
2023-06-01T23:52:07.313828+00:00 app[worker.1]:                              params)                                            
2023-06-01T23:52:07.313828+00:00 app[worker.1]:                                File "/lichess.py", line 230,                    
2023-06-01T23:52:07.313828+00:00 app[worker.1]:                              in challenge                                       
2023-06-01T23:52:07.313828+00:00 app[worker.1]:                                  return                                         
2023-06-01T23:52:07.313828+00:00 app[worker.1]:                              self.api_post("challenge",                         
2023-06-01T23:52:07.313829+00:00 app[worker.1]:                              username, payload=payload,                         
2023-06-01T23:52:07.313829+00:00 app[worker.1]:                              raise_for_status=False)                            
2023-06-01T23:52:07.313829+00:00 app[worker.1]:                                File                                             
2023-06-01T23:52:07.313829+00:00 app[worker.1]:                              "/usr/local/lib/python3.9/dist-pa                  
2023-06-01T23:52:07.313829+00:00 app[worker.1]:                              ckages/backoff/_sync.py", line                     
2023-06-01T23:52:07.313833+00:00 app[worker.1]:                              105, in retry                                      
2023-06-01T23:52:07.313833+00:00 app[worker.1]:                                  ret = target(*args, **kwargs)                  
2023-06-01T23:52:07.313833+00:00 app[worker.1]:                                File "/lichess.py", line 134,                    
2023-06-01T23:52:07.313833+00:00 app[worker.1]:                              in api_post                                        
2023-06-01T23:52:07.313834+00:00 app[worker.1]:                                  json_response:                                 
2023-06-01T23:52:07.313834+00:00 app[worker.1]:                              JSON_REPLY_TYPE = response.json()                  
2023-06-01T23:52:07.313834+00:00 app[worker.1]:                                File                                             
2023-06-01T23:52:07.313834+00:00 app[worker.1]:                              "/usr/local/lib/python3.9/dist-pa                  
2023-06-01T23:52:07.313834+00:00 app[worker.1]:                              ckages/requests/models.py", line                   
2023-06-01T23:52:07.313834+00:00 app[worker.1]:                              975, in json                                       
2023-06-01T23:52:07.313835+00:00 app[worker.1]:                                  raise                                          
2023-06-01T23:52:07.313835+00:00 app[worker.1]:                              RequestsJSONDecodeError(e.msg,                     
2023-06-01T23:52:07.313835+00:00 app[worker.1]:                              e.doc, e.pos)                                      
2023-06-01T23:52:07.313835+00:00 app[worker.1]:                              requests.exceptions.JSONDecodeErr                  
2023-06-01T23:52:07.313835+00:00 app[worker.1]:                              or: Expecting value: line 1                        
2023-06-01T23:52:07.313835+00:00 app[worker.1]:                              column 1 (char 0)                                  
2023-06-01T23:52:07.315395+00:00 app[worker.1]:                     INFO     Challenge id is None.            matchmaking.py:161
MarkZH commented 1 year ago

The lichess servers limit how many challenges a bot can issue per day. Your bot has hit that limit, so lichess.org is rejecting an further challenges until the number of challenges in the past 24 hours falls below some limit.

Are you running multiple concurrent instances of lichess-bot?

FatFritz2 commented 1 year ago

No I just use 1 instance

2023-06-03T13:06:02.531695+00:00 app[worker.1]: [06/03/23 13:06:02] INFO     Challenging a random bot         matchmaking.py:156
2023-06-03T13:06:02.533570+00:00 app[worker.1]:                     INFO     Seeking rated game with opponent matchmaking.py:111
2023-06-03T13:06:02.533571+00:00 app[worker.1]:                              rating in [600, 4000] ...                          
2023-06-03T13:06:05.672549+00:00 app[worker.1]: [06/03/23 13:06:05] ERROR    No suitable bots found to        matchmaking.py:144
2023-06-03T13:06:05.672559+00:00 app[worker.1]:                              challenge.                                         
2023-06-03T13:06:05.673724+00:00 app[worker.1]:                     INFO     Will challenge None for a rated  matchmaking.py:159
2023-06-03T13:06:05.673724+00:00 app[worker.1]:                              game.                                              
2023-06-03T13:06:05.674714+00:00 app[worker.1]:                     INFO     Challenge id is None.            matchmaking.py:161
MarkZH commented 1 year ago

The fastest way to fix this is to turn off lichess-bot for at least a few hours, a day to be certain. That way, the count of challenges will be zero and there will be no limits. Lichess-bot keeps a record of the challenges in the past 24 hours in the file daily_challenge_times.txt. If this list grows too long, lichess-bot will slow down the rate of issuing challenges. That should prevent future rate limiting, even if lichess-bot needs to be restarted.

MarkZH commented 1 year ago

Is this still a problem?

FatFritz2 commented 1 year ago

I tried to create a new token and it worked :D