charlesbel/Microsoft-Rewards-Farmer

[BUG] "Unable to connect to Chrome" Error Fix

Grenade-Inspector opened this issue · 3 comments

Before submitting a bug report...

  • This bug wasn't already reported.
    (I have checked every bug report on GitHub)

Title

  • The title is no longer "[BUG] Title" and I edited it with the right error name.

Describe the bug

The bug itself, isn't exactly a bug, but works like one. If you close the script early or just simply let the script finish, it will leave 3-4 different processes of chrome running, which you can check via task manager, chrome is a resource heavy web browser, so this eventually takes up 100% of your CPU, then gives the error that everyone has been reporting, which is something along the lines of "unable to connect to chrome". This can be fixed by adding a line or function to clear the processes or kill every chrome processes running (this second solution isn't the best due to some users of this script actually using Google Chrome and it would mess up their tabs or whatever). I found this error and fix on Windows 10 Version 22H2, so this error might not effect people who use Linux headless servers or Linux itself.

Sidenote: I assume this project is abandoned, so if anyone who forks this guy's repository could implement these 3-4 lines of code, then it would be most appreciated. It would just make sure it's actually closing the driver at the end of the script or close all processes with the name "Google Chrome".

Copy and paste your error

I don't have the error code because I've started just closing the tabs manually after running the script, but there are tons of bug reports showcasing this error.

Screenshots

Screenshot 2023-11-24 050432
(I don't use Google Chrome as my web browser, so this was solely caused by the script.)

I run it using .bat file to run the code. You can try use this:
image

I run it using .bat file to run the code. You can try use this: image

Yes this would work, however you've hard coded your specific Windows username into the command to cd into the directory of the program, and you also didn't account that people might move the directory to documents or even a different drive. I mean the fix you've got above will work, but for only yourself (kind of, see below), what I did was ask ChatGPT for the specific lines of code to look for any processes running using the "chrome.exe" file, and this has worked, I just set it up as a function and call it at the start of the script before any accounts are loaded, between accounts (switching accounts), and at the very end after all accounts have been farmed.

(This is what I meant by see below) - Yes the fix does work for you, but if you had more like probably 5 accounts, then it would start to become a problem, so I think a .bat file is just the wrong way to fix this error, so python code itself would be better. I have a fairly decent pc, I won't get into specifics, but it is at 100% CPU usage after just 4 or 5 accounts, so you'd want to close the chrome processes either how I've said above or find a way to ensure that selenium actually closes the processes like it is suppose to (there is a line of code to prevent this exact error from occurring).

I've just seen that someone called "CodeBanana69" has actually forked this project and added a function containing the python code to fix this error, so this error is pretty much fixed, but I'll leave it open just in case the original developer wants to make any of these changes.