Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

504 GATEWAY_TIMEOUT in ajax call

I have ajax call where I process large data and then reload the page in ajax success. Ajax call is

        $.ajax({
            type:'POST',
            cache:false,
            async:false,
            url: 'URL',
            data: "",
            timeout:0,
            beforeSend:function(msgg){   
                $('#loading').show();
            },
            success: function(data){
                if(data == "success")
                {
                    setTimeout(function(){
                        $('#loading').hide();
                        window.location.reload();
                    },5000);
                }
            }
        });

but it gets 504 GATEWAY_TIMEOUT and ajax call never comes in success. I need manual refresh.

like image 944
hrishi Avatar asked Oct 19 '22 00:10

hrishi


People also ask

Does Ajax call timeout?

Session timeout has been a very common feature in Ajax-based web applications. In responsive interface, the programmer needs to delay the ajax request to achieve some task before the response.

What is default Ajax timeout?

The executionTimeout attribute exists under httpRequest in the Machine.config file. Set a local timeout (in milliseconds) for the request. The default Ajax request is set to 90 seconds.

What is the reason for 504 Gateway Timeout?

The HyperText Transfer Protocol (HTTP) 504 Gateway Timeout server error response code indicates that the server, while acting as a gateway or proxy, did not get a response in time from the upstream server that it needed in order to complete the request.


1 Answers

504 GATEWAY_TIMEOUT errors normally occur when your API Gateway URL is not responsive. It could be some kind of internal Gateway error.

Here are some steps to troubleshoot:

  • Use a proxy like Postman to make the same exact request and see what the response is
  • Make sure your path is correct
  • If there are other requests that you make to the same gateway URL, maybe a GET request, try making those calls manually or using your code, to make sure the gateway is working fine
  • If you have access to the Gateway, restart it (this is possible if you have Microservices architecture, and Dockerisation etc)
like image 129
nikjohn Avatar answered Oct 21 '22 00:10

nikjohn