Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ServerError: 503 Server Error: Service Temporarily Unavailable #56

Open
orel35 opened this issue Jun 2, 2021 · 19 comments
Open

ServerError: 503 Server Error: Service Temporarily Unavailable #56

orel35 opened this issue Jun 2, 2021 · 19 comments

Comments

@orel35
Copy link

orel35 commented Jun 2, 2021

Traceback (most recent call last):
File "C:\perso\tools\docto\doctoshotgun.py", line 506, in
sys.exit(Application().main())
File "C:\perso\tools\docto\doctoshotgun.py", line 433, in main
if not docto.do_login():
File "C:\perso\tools\docto\doctoshotgun.py", line 192, in do_login
self.open('https://www.doctolib.fr/sessions/new')
File "C:\Users\aurel\AppData\Local\Programs\Python\Python39\lib\site-packages\woob\browser\browsers.py", line 898, in open
return super(PagesBrowser, self).open(callback=internal_callback, *args, **kwargs)
File "C:\Users\aurel\AppData\Local\Programs\Python\Python39\lib\site-packages\woob\browser\browsers.py", line 790, in open
return super(DomainBrowser, self).open(req, *args, **kwargs)
File "C:\Users\aurel\AppData\Local\Programs\Python\Python39\lib\site-packages\woob\browser\browsers.py", line 531, in open
response = self.session.send(preq,
File "C:\perso\tools\docto\doctoshotgun.py", line 57, in send
return callback(self, resp)
File "C:\Users\aurel\AppData\Local\Programs\Python\Python39\lib\site-packages\woob\browser\browsers.py", line 527, in inner_callback
self.raise_for_status(response)
File "C:\Users\aurel\AppData\Local\Programs\Python\Python39\lib\site-packages\woob\browser\browsers.py", line 563, in raise_for_status
raise ServerError(http_error_msg, response=response)
woob.browser.exceptions.ServerError: 503 Server Error: Service Temporarily Unavailable

@nicolaus-hee
Copy link
Contributor

Do you get this consistently? Usually, trying again will 'resolve' it.

Possibly related to #31 , #21

@rbignon
Copy link
Owner

rbignon commented Jun 3, 2021

I can't reproduce.

@sgoendoer
Copy link

Hi,
I started to get this also. First from time to time, then permanently. My assumption is that the guys at Doctolib figured that someone is using a (this) script and started blocking it. Not sure if this generally detects this script and blocks it or if this is an IP-based blocking.

@porlk
Copy link

porlk commented Jun 7, 2021

I can confirm to have had the same issue. In my case, the casing of the city name was the cause (eg. you should write paris or grenoble instead of Paris and Grenoble).

@gitolicious
Copy link
Collaborator

I tried to learn a bit more about this error. For me it's CloudFlare blocking my requests.

    def do_login(self):
        while True:
            retryAfterLoginError = False
            try:
                self.open(self.BASEURL + '/sessions/new')
            except ServerError as e:
                if e.response.status_code in [503]:
                    if 'text/html' in e.response.headers['Content-Type'] and 'cloudflare' in e.response.text:
                        log('Request blocked by CloudFlare', color='red')
                    log('Login failed. Retrying in 10s...')
                    self.session.close()
                    retryAfterLoginError = True
                    sleep(10)
                else:
                    raise
            if retryAfterLoginError == False:
                break

With this change, the login is retried though I didn't have any success even after multiple retries.

$ ./doctoshotgun.py de koln [email protected] password --dry-run
Request blocked by CloudFlare
Login failed. Will retry in 10 sec
Request blocked by CloudFlare
Login failed. Will retry in 10 sec

Stopping and starting the script immediately after helps sometimes though. This is weird behavior.

$ ./doctoshotgun.py de koln [email protected] password --dry-run
Request blocked by CloudFlare
Login failed. Will retry in 10 sec
^CAbort.
$ ./doctoshotgun.py de koln [email protected] password --dry-run
Starting to look for vaccine slots for John Doe between 2021-06-12 and 2021-06-19...
Vaccines: Pfizer, Moderna, Janssen
Country: de
This may take a few minutes/hours, be patient!

@rbignon
Copy link
Owner

rbignon commented Jun 12, 2021

That's strange, I never experienced this… Do you use the latest version of cloudscraper, and do you run your script from a home ISP (not from a server)?

@nicarl
Copy link

nicarl commented Jun 12, 2021

I saw the problem only when running from a VPS and after some days (the IP address of the VPS never changes).

@rbignon
Copy link
Owner

rbignon commented Jun 12, 2021

Yes, I guess it is harder to bypass cloudflare from a server.

@gitolicious
Copy link
Collaborator

gitolicious commented Jun 12, 2021

I was running the script inside a Docker container. When doing so on my laptop (VS Code Dev Container as well as Alpine base image) I got 503s from time to time (~2 out of 10), when doing so on my Odroid N2+ smart home central (Linux OS without a Desktop) it happens most of the time (~9 out of 10). Seems like cloudscaper doesn't play nice with Non-UI environments and that's something doctoshotgun is not to blame for.

@gitolicious
Copy link
Collaborator

After playing around more with the script, in my Docker environments it is a hit and miss. Once it is running, it works fine all the way - if it starts with a Cloudflare error this seems not to be recoverable with waiting loops. I will add the more detailed error message but not the retries.

@lurkaround
Copy link

I never get past this error running the script on my local machine. Per #21, I don't guess this has been fixed yet?

@gitolicious
Copy link
Collaborator

Are you blocked by the Cloudflare check or what response are you getting?

@Lvrks
Copy link

Lvrks commented Jun 23, 2021

Whoops, probably should have included this initially. Here's the log:
Traceback (most recent call last): File "C:\Users\tools\doctoshotgun\doctoshotgun.py", line 869, in <module> sys.exit(Application().main()) File "C:\Users\tools\doctoshotgun\doctoshotgun.py", line 698, in main if not docto.do_login(): File "C:\Users\tools\doctoshotgun\doctoshotgun.py", line 216, in do_login self.open(self.BASEURL + "/sessions/new") File "C:\Python39\lib\site-packages\woob\browser\browsers.py", line 898, in open return super(PagesBrowser, self).open(callback=internal_callback, *args, **kwargs) File "C:\Python39\lib\site-packages\woob\browser\browsers.py", line 790, in open return super(DomainBrowser, self).open(req, *args, **kwargs) File "C:\Python39\lib\site-packages\woob\browser\browsers.py", line 531, in open response = self.session.send(preq, File "C:\Users\tools\doctoshotgun\doctoshotgun.py", line 64, in send return callback(self, resp) File "C:\Python39\lib\site-packages\woob\browser\browsers.py", line 527, in inner_callback self.raise_for_status(response) File "C:\Python39\lib\site-packages\woob\browser\browsers.py", line 563, in raise_for_status raise ServerError(http_error_msg, response=response) woob.browser.exceptions.ServerError: 503 Server Error: Service Temporarily Unavailable

@gitolicious
Copy link
Collaborator

I was able to reproduce this in a Docker environment. This is what I see in the HTML response:

Checking your browser before accessing doctolib.de.
This process is automatic. Your browser will redirect to your requested content shortly.
Please allow up to 5 seconds
Redirecting

So this is a Cloudflare check that blocks the request which is not identified by the changes in #74. (More info on this "Dynamic Analysis" can be found here)

I am unsure if this means cloudscraper has ultimately failed to circumvent the Cloudflare checks, or it will handle it once we raise the error.

@gitolicious
Copy link
Collaborator

We now have explanatory error messages and nothing else we can do other than retrying or hoping for cloudscraper to improve.

@tobiasBora
Copy link

tobiasBora commented Jul 18, 2021

I can also confirm this, with the enhanced cloudflare log message PR I get a similar error Request blocked by CloudFlare. This was run locally.

Request blocked by CloudFlare
Traceback (most recent call last):
  File "/tmp/nix-shell.DpTZUZ/tmp.IIan1yyEqe/bin/doctoshotgun.py", line 7, in <module>
    exec(compile(f.read(), __file__, 'exec'))
  File "/home/me/doctoshotgun/doctoshotgun.py", line 863, in <module>
    sys.exit(Application().main())
  File "/home/me/doctoshotgun/doctoshotgun.py", line 686, in main
    if not docto.do_login(args.code):
  File "/home/me/doctoshotgun/doctoshotgun.py", line 259, in do_login
    self.open(self.BASEURL + '/sessions/new')
  File "/nix/store/vjz7gf1v4jicn88v2m6a7knyshzqbv25-python3.8-woob-3.0/lib/python3.8/site-packages/woob/browser/browsers.py", line 898, in open
    return super(PagesBrowser, self).open(callback=internal_callback, *args, **kwargs)
  File "/nix/store/vjz7gf1v4jicn88v2m6a7knyshzqbv25-python3.8-woob-3.0/lib/python3.8/site-packages/woob/browser/browsers.py", line 790, in open
    return super(DomainBrowser, self).open(req, *args, **kwargs)
  File "/nix/store/vjz7gf1v4jicn88v2m6a7knyshzqbv25-python3.8-woob-3.0/lib/python3.8/site-packages/woob/browser/browsers.py", line 531, in open
    response = self.session.send(preq,
  File "/home/me/doctoshotgun/doctoshotgun.py", line 74, in send
    return callback(self, resp)
  File "/nix/store/vjz7gf1v4jicn88v2m6a7knyshzqbv25-python3.8-woob-3.0/lib/python3.8/site-packages/woob/browser/browsers.py", line 527, in inner_callback
    self.raise_for_status(response)
  File "/nix/store/vjz7gf1v4jicn88v2m6a7knyshzqbv25-python3.8-woob-3.0/lib/python3.8/site-packages/woob/browser/browsers.py", line 563, in raise_for_status
    raise ServerError(http_error_msg, response=response)
woob.browser.exceptions.ServerError: 503 Server Error: Service Temporarily Unavailable

@gitolicious
Copy link
Collaborator

Did it work for you when retrying right away?

@flrnt
Copy link

flrnt commented Nov 30, 2021

same error here, tried using a proxy (germany, spain, argentina, belgium, whatever..) but none worked

@Stephan972
Copy link

I get stuck with the very same error. I'm connecting from my home (ie no VPS). Any try is a complete failure (even with large pause between two attempts).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests