klept0 / MS-Rewards-Farmer

A simple bot that uses Selenium to farm M$ Rewards in Python
MIT License
254 stars 53 forks source link

Timeout Exception after a few searches as in #185 #221

Open iDarkSnow opened 2 weeks ago

iDarkSnow commented 2 weeks ago

Before submitting a bug report...

Branch

master

Commit

Latest

Describe the bug

After a few searches, on both the accounts, the script stops with a TimeoutException. This bug was already reported in #185 and it seemed to be solved in a future commit, but it still happens on my end.

Copy and paste your error

[38;21m2024-11-05 09:32:01,025 [DEBUG] in exit exc_type=<class 'selenium.common.exceptions.TimeoutException'> exc_value=Message: Stacktrace: GetHandleVerifier [0x003738B3+24035] (No symbol) [0x002FBC44] (No symbol) [0x001DC2D3] (No symbol) [0x0021DC86] (No symbol) [0x0021DECB] (No symbol) [0x0025B9D2] (No symbol) [0x0023FED4] (No symbol) [0x0025953F] (No symbol) [0x0023FC26] (No symbol) [0x0021218C] (No symbol) [0x0021310D] GetHandleVerifier [0x006196D3+2800643] GetHandleVerifier [0x0067428E+3172286] GetHandleVerifier [0x0066CEA2+3142610] GetHandleVerifier [0x00416C60+692624] (No symbol) [0x00304C5D] (No symbol) [0x00301968] (No symbol) [0x00301B00] (No symbol) [0x002F3FB0] BaseThreadInitThunk [0x76727BA9+25] RtlInitializeExceptionChain [0x7779C0CB+107] RtlClearBits [0x7779C04F+191] traceback=<traceback object at 0x000001B53E874140>←[0m ←[38;5;196m2024-11-05 09:32:03,464 [ERROR] ←[0m Traceback (most recent call last): File "C:\Microsoft Rewards\MS-Rewards-Farmer\main.py", line 40, in main earned_points = executeBot(currentAccount, args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Microsoft Rewards\MS-Rewards-Farmer\main.py", line 249, in executeBot searches.bingSearches() File "C:\Microsoft Rewards\MS-Rewards-Farmer\src\searches.py", line 136, in bingSearches self.bingSearch() File "C:\Microsoft Rewards\MS-Rewards-Farmer\src\searches.py", line 171, in bingSearch searchbar = self.browser.utils.waitUntilClickable( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Microsoft Rewards\MS-Rewards-Farmer\src\utils.py", line 81, in waitUntilClickable return WebDriverWait(self.webdriver, timeToWait).until( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\aless\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\support\wait.py", line 105, in until raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: Stacktrace: GetHandleVerifier [0x003738B3+24035] (No symbol) [0x002FBC44] (No symbol) [0x001DC2D3] (No symbol) [0x0021DC86] (No symbol) [0x0021DECB] (No symbol) [0x0025B9D2] (No symbol) [0x0023FED4] (No symbol) [0x0025953F] (No symbol) [0x0023FC26] (No symbol) [0x0021218C] (No symbol) [0x0021310D] GetHandleVerifier [0x006196D3+2800643] GetHandleVerifier [0x0067428E+3172286] GetHandleVerifier [0x0066CEA2+3142610] GetHandleVerifier [0x00416C60+692624] (No symbol) [0x00304C5D] (No symbol) [0x00301968] (No symbol) [0x00301B00] (No symbol) [0x002F3FB0] BaseThreadInitThunk [0x76727BA9+25] RtlInitializeExceptionChain [0x7779C0CB+107] RtlClearBits [0x7779C04F+191]

←[38;5;226m2024-11-05 09:32:03,468 [WARNING] config-private.yaml doesn't exist←[0m ←[38;21m2024-11-05 09:32:03,468 [DEBUG] No urls found, not sending notification←[0m ←[38;5;39m2024-11-05 09:32:03,469 [INFO] [POINTS] Data saved for the next day.←[0m

Screenshots

N/A

Value of dashboard variable

N/A

cal4 commented 2 weeks ago

Try develop

iDarkSnow commented 2 weeks ago

I did but I found it confusing, is there a way to check progress during the execution of the script from the develop branch? I found nothing in the argumentParser function

cal4 commented 2 weeks ago

I'm assuming you mean via logging? You can change logging.level in config.yaml to DEBUG from INFO to get more granular logs. Think the default log level changed which explains the confusion.

iDarkSnow commented 2 weeks ago

Yes, exactly what I meant. Sorry for my lack of clarity. It seems to be running as expected now, thank you. I will update as soon as the script finishes, hopefully to close the issue :)

cal4 commented 2 weeks ago

All good, glad to hear

iDarkSnow commented 2 weeks ago

Update: while desktop searches finish without problems, mobile searches are stuck on 20 remaining even though the search terms are changing. Is it a known issue? The script has been running since 2:23 PM GMT+1

iDarkSnow commented 2 weeks ago

After running the scheduled task generated with the dedicated python script, this morning i got an assertion error on PCSearch: Traceback (most recent call last): File "C:\Microsoft Rewards\MS-Rewards-Farmer\main.py", line 39, in main earned_points = executeBot(currentAccount, args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Microsoft Rewards\MS-Rewards-Farmer\main.py", line 246, in executeBot searches.bingSearches() File "C:\Microsoft Rewards\MS-Rewards-Farmer\src\searches.py", line 110, in bingSearches desktopAndMobileRemaining = self.browser.getRemainingSearches( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Microsoft Rewards\MS-Rewards-Farmer\src\browser.py", line 283, in getRemainingSearches pcSearch: dict = counters["PCSearch"][0]


KeyError: 'PCSearch'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Microsoft Rewards\MS-Rewards-Farmer\main.py", line 347, in <module>
    main()
  File "C:\Microsoft Rewards\MS-Rewards-Farmer\main.py", line 42, in main
    sendNotification(
  File "C:\Microsoft Rewards\MS-Rewards-Farmer\src\utils.py", line 273, in sendNotification
    assert apprise.notify(title=str(title), body=str(body))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
cal4 commented 2 weeks ago

Update: while desktop searches finish without problems, mobile searches are stuck on 20 remaining even though the search terms are changing. Is it a known issue? The script has been running since 2:23 PM GMT+1

Doesn't happen to me

After running the scheduled task generated with the dedicated python script, this morning i got an assertion error on PCSearch: Traceback (most recent call last): File "C:\Microsoft Rewards\MS-Rewards-Farmer\main.py", line 39, in main earned_points = executeBot(currentAccount, args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Microsoft Rewards\MS-Rewards-Farmer\main.py", line 246, in executeBot searches.bingSearches() File "C:\Microsoft Rewards\MS-Rewards-Farmer\src\searches.py", line 110, in bingSearches desktopAndMobileRemaining = self.browser.getRemainingSearches( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Microsoft Rewards\MS-Rewards-Farmer\src\browser.py", line 283, in getRemainingSearches pcSearch: dict = counters["PCSearch"][0] ~~~~^^^^^^^^^^^^ KeyError: 'PCSearch'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Microsoft Rewards\MS-Rewards-Farmer\main.py", line 347, in main() File "C:\Microsoft Rewards\MS-Rewards-Farmer\main.py", line 42, in main sendNotification( File "C:\Microsoft Rewards\MS-Rewards-Farmer\src\utils.py", line 273, in sendNotification assert apprise.notify(title=str(title), body=str(body)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError

See https://github.com/klept0/MS-Rewards-Farmer/pull/208#issuecomment-2459863370. Don't think the scheduled task contributes to this problem.

iDarkSnow commented 2 weeks ago

So there is nothing i can do to fix the AssertionError?

cal4 commented 2 weeks ago

You mean the KeyError? The AssertionError is occurring because a notification should've been sent, but wasn't able to be sent for some reason.

As far as the KeyError, it's a known-issue. The only workaround I've noticed is that if you just logged-in, it can take a little bit for this call to work correctly.

iDarkSnow commented 2 weeks ago

Yes sorry, i guess the AssertionError comes as a consequence of the KeyError. I get the KeyError as soon as researches start after daily tasks now, i also cleared my sessions folder but the issue persist. Could you explain the workaround a little further? I didn't quite understand your solution, sorry

cal4 commented 2 weeks ago

Basically spam the runs after logging in. It takes a bit for the cookies/auth to be in place so that you can access the remaining searches.

And just to be clear, the AssertionError isn't a consequence of the KeyError. If you've configured your bot to send notifications on failures, it can't do that currently most likely due to your config. Basically it's saying the bot tried to send a notification, but it wasn't successfully sent. Since we expect this to work at this point in the program, the assertion fails and throws an exception.

iDarkSnow commented 2 weeks ago

I did not configure the bot to send any notifications, i didn't find anything in the project readme, but i understand now the two errors are not linked. And is it also default behaviour that when this sequence of errors happens the script stops and i get returned to the command line? Shouldn't it move to the next account/research type (e.g. from desktop to mobile searches)?

cal4 commented 2 weeks ago

It should work that way in regards to accounts, see https://github.com/klept0/MS-Rewards-Farmer/blob/50dc6dcfb10ac3afe1fccadb7dd33738bc69fc66/main.py#L37-L47

As far as attempting mobile if desktop fails, I'm pretty confident that if you can't get the remaining searches (or access account info more generally) for one you can't for the other. Try commenting out code or just running mobile searches to see.

In regards to notifications, do you have a config-private.yaml file?

iDarkSnow commented 2 weeks ago

I do have a config-private.yaml file in my directory, though it is configured as follows, so probably serves nothing as i haven't added any additional configurations:

# Copy this file to config-private.yaml to use
apprise:
  urls:
    - 'discord://WebhookID/WebhookToken'  # Replace with your actual Apprise service URLs
cal4 commented 2 weeks ago

Yeah, since you have an entry under urls the bot will try to send a notification. It can't really figure whether the url is legit or not, and obviously this one'll fail because there's no token.

I'd recommend getting rid of config-private.yaml if you don't plan to use it or get rid of the urls entry.

iDarkSnow commented 2 weeks ago

Yes, that did the trick for the AssertionError. I only get stuck on the KeyError now, even though for some reason my output doesn't contain DEBUG level info anymore?

cal4 commented 2 weeks ago

Not happening for me, double check the config and pull the latest from develop

perhorst1234 commented 2 weeks ago

Hi, I have the same issue but when i try the develop branch the output was this -bash: syntax error near unexpected token `('

iDarkSnow commented 2 weeks ago

Not happening for me, double check the config and pull the latest from develop

I deleted the whole repo and cloned it back again, removed the config-private file and edited the config file to use DEBUG level logging, same thing happens where i don't get logging in the output of the script. Any idea what might cause this issue?

iDarkSnow commented 2 weeks ago

I confirm that the DEBUG level logging came back as soon as i restored the config-private.yaml file even though it still contains the placeholder link but doing so brought back the PCSearch KeyError. So the current situation is the following:

These things do not seem related to me, do you have any idea of what it might be?

perhorst1234 commented 2 weeks ago

and I get this error now ERROR:root: Traceback (most recent call last): File "/home/MS-Rewards-Farmer-develop/MS-Rewards-Farmer-develop/main.py", line 39, in main earned_points = executeBot(currentAccount, args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/MS-Rewards-Farmer-develop/MS-Rewards-Farmer-develop/main.py", line 234, in executeBot with Browser(mobile=False, account=currentAccount, args=args) as desktopBrowser: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/MS-Rewards-Farmer-develop/MS-Rewards-Farmer-develop/src/browser.py", line 41, in init self.localeLang, self.localeGeo = self.getLanguageCountry(args.lang, args.geo) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/MS-Rewards-Farmer-develop/MS-Rewards-Farmer-develop/src/browser.py", line 234, in getLanguageCountry ).alpha_2 ^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/pycountry/db.py", line 16, in getattr raise AttributeError(key) AttributeError: alpha_2

TheBrokenG0d commented 1 week ago

I confirm that the DEBUG level logging came back as soon as i restored the config-private.yaml file even though it still contains the placeholder link but doing so brought back the PCSearch KeyError. So the current situation is the following:

  • Removing the config-private.yaml file seems to make searches start and removes both the KeyError and AssertionError, but for some reason it stops the correct functioning of the logging of the script;
  • Having the config-private.yaml file seems to break the script by introducing a KeyError.

These things do not seem related to me, do you have any idea of what it might be?

I can confirm this too, If I don't have a config-private.yaml the debug doesn't work. Starting with a fresh dev branch install I had to rename the private-config template file for the debug logging to work.