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

503 Service Unavailable #320

Open
Jones-S opened this issue Sep 15, 2019 · 4 comments
Open

503 Service Unavailable #320

Jones-S opened this issue Sep 15, 2019 · 4 comments

Comments

@Jones-S
Copy link

Jones-S commented Sep 15, 2019

Hi there. Another issue by me. So sorry about it 🙏🏼

Now that I bought the plugin and deployed the live site, graphql just returns random 503 Service Unavailable errors...

Does anyone have a clue why?
It never happened before (except due to some strange behaviour in my other issue (#307).

And now it starts happening on the live page, just for some requests via apollo and even when building the page from netlify:

Screenshot 2019-09-15 at 13 19 11

The only thing that has changed, is that my live page still is waiting for the SSL the be provisioned, but that's about it.
I doubt that the server is down every few requests too...

Maybe it has to do with CORS issues again:
image

And also:
Failed to load resource: Origin http://www.live-site.ch is not allowed by Access-Control-Allow-Origin.

I do have a config/craftql.php file where I have stated:

'allowedOrigins' => [
      '*'
    ]

So it should actually be allowed...

I really don't know where this could originate from...
Any hint would be very welcome...

Error logs from Server:
You can see every now and then there is a 503. 🤷‍♂️

80....IP...40 - - [15/Sep/2019:13:48:16 +0200] "POST /api HTTP/1.1" 503 26992 "-" "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"
80....IP...40 - - [15/Sep/2019:13:48:16 +0200] "POST /api HTTP/1.1" 200 2758 "-" "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"
80....IP...40 - - [15/Sep/2019:13:48:16 +0200] "POST /api HTTP/1.1" 200 1049 "-" "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"
80....IP...40 - - [15/Sep/2019:13:48:16 +0200] "POST /api HTTP/1.1" 200 3239 "-" "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"
80....IP...40 - - [15/Sep/2019:13:48:16 +0200] "POST /api HTTP/1.1" 200 3423 "-" "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"
80....IP...40 - - [15/Sep/2019:13:48:16 +0200] "POST /api HTTP/1.1" 200 3247 "-" "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"
80....IP...40 - - [15/Sep/2019:13:48:16 +0200] "POST /api HTTP/1.1" 200 3459 "-" "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"
80....IP...40 - - [15/Sep/2019:13:48:16 +0200] "POST /api HTTP/1.1" 200 1937 "-" "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"
80....IP...40 - - [15/Sep/2019:13:48:16 +0200] "POST /api HTTP/1.1" 200 3459 "-" "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"
80....IP...40 - - [15/Sep/2019:13:48:16 +0200] "POST /api HTTP/1.1" 200 5858 "-" "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"
80....IP...40 - - [15/Sep/2019:13:48:16 +0200] "POST /api HTTP/1.1" 503 26992 "-" "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"
80....IP...40 - - [15/Sep/2019:13:48:16 +0200] "POST /api HTTP/1.1" 503 26992 "-" "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"
80....IP...40 - - [15/Sep/2019:13:48:16 +0200] "POST /api HTTP/1.1" 503 26992 "-" "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"
80....IP...40 - - [15/Sep/2019:13:48:16 +0200] "POST /api HTTP/1.1" 200 5858 "-" "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"

... 🤔 could it be that the request times out?
All 503 errors have a number next to them: 26992 Is this the time for the request in milliseconds?

@narration-sd
Copy link
Contributor

narration-sd commented Sep 15, 2019

Jonas, this as with many things in modern development probably means you'll need to exercise your Google-fu...

Here on a Sunday are a couple of items that look like they might hint at CORS specifics that can happen with Netlify:

I don't think it's timeouts -- 503 is a hard refusal from the server, as you can also look up.

@narration-sd
Copy link
Contributor

p.s. good if you post what you find actually solves this, nice for others to find

@Jones-S
Copy link
Author

Jones-S commented Sep 16, 2019

Actually I did find a solution – at least it made the error go away:

I thought – because of the suspicion that the timeout was a problem – that I could just redo the apollo call. So I used:
https://www.apollographql.com/docs/link/links/retry/

This means if the request fails it will just redo it.
This got all my netlify builds go through smoothly and I resolved weird errors within the running app.

I am still not sure, if it was a timeout thing, and maybe my retry.stuff is just covering the underlying problem. I will try to investigate more, but for now I am just glad I got the project up and running again.

Thank you very much for your quick responses. I really appreciate this!
I hope some of my numerous questions maybe help somebody else one day.
I will try to up my google-game ;).
Weirdly it only appeared after the project went life and we had a pre-version online on netlify for almost 2 weeks and I never experienced this error before...

@Jones-S
Copy link
Author

Jones-S commented Sep 16, 2019

Oh hey: this could be it:

Second of all, this problem is happening because you’re hitting an https:// API from http://localhost, which doesn’t have SSL, so the problem could go away once you deploy onto an https enabled domain

from https://alligator.io/nodejs/solve-cors-once-and-for-all-netlify-dev/

I was still waitint for the certificate to be provisioned (because there was an additional AAAA record I forgot to delete). During that time the domain was still http requesting the API.

What to me still does not make sense, is, why a netlify build would be influenced by the domain, where the live page is shown.
I mean is my request during a build a different one, if the page that is deployed is using the http protocol, than if the deployed page is using https? 🤷‍♂️
(Also when calling the API from http://localhost:3000 it always worked like a charm, so I did not think of an SSL problem...)

Anyway, as I said I will keep investigating.

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

2 participants