Cloudflare error 524 workaround
« on: August 21, 2020, 01:50:50 AM »
Hi!
I am using cludflare on site and getting 524 error.
I found this on cloudflare support:
Background
Error 524 error indicates that Cloudflare made a successful TCP connection to the origin web server, but the origin did not reply with an HTTP response before the connection timed out. Typically, Cloudflare waits 100 seconds for an HTTP response. If the origin doesn’t respond in that time, Cloudflare closes the connection and you’ll see “Error 524: A timeout occurred”.

Quick Fix Ideas

    1. This error is commonly caused by a long-running process on the origin server, such as a PHP application or a database query which the web server must wait on before responding to a request. This can also be caused by your origin server being overloaded - so as a first step it’s a good idea to check your server’s available resources, including CPU and RAM, and overall traffic levels. If your server has a high CPU load, or is low on memory, this could indicate a resource problem.

   2.  Investigate for issues at your origin server that might result in responses taking longer than 100 seconds to be generated. Ask your hosting provider/system administrator to check if there are any server issues. Reviewing your webserver access/error logs would be a good place to locate this information. If you have a Cloudflare Enterprise plan, contact Cloudflare Customer Support to make them aware of the issue to investigate options.

   3.  You should check your server health metrics such as available CPU & RAM and if you’re using a Database server, that should be checked as well for long-running queries. Review your origin webserver access/error logs which may provide more information on why those requests are timing out.

 4.    If you need to have scripts that run for longer than around 100 seconds without returning any data to the browser, you can’t run these through Cloudflare. There are a couple of options: Run the scripts via a grey-clouded subdomain or change the script so that it kicks off a long-running background process and quickly returns a status which the browser can poll until the background process has completed, at which point the full response can be returned. This is the way most people do this type of action as keeping HTTP connections open for a long time is unreliable and can be very taxing also.

I believe the 524 error is explained on point 4 above.

Any ideas for a workaround to avoid 524 error?

Thanks!

 
Re: Cloudflare error 524 workaround
« Reply #1 on: August 21, 2020, 10:40:56 AM »
Hello, 

in this case I would recommend to run generator in command line if you have ssh access to your server.
Re: Cloudflare error 524 workaround
« Reply #2 on: August 22, 2020, 04:51:33 AM »
Hi Oleg
Thanks a lot for the suggestion.
The issue with using ssh is that it can't be automated , for example, with cron.
Let me ask you..
It is possible to do something (minor hack or edit on script) to make the script return data to the browser every X seconds to prevent the 100 seconds cloudflare limit before it shuts the connection?
Thanks a lot!