CloudFlare time-out in 100 seconds

I am trying to run my reports AJAX-ify to bypass the 100 second timeout that CloudFlare imposes on requests that go through its site.

See Is it Possible to Increase CloudFlare Timeout?

I have done the following:

function ajaxReport() {
    var seconds = prompt("Please enter how many seconds you want the report to run", "5");
    $('#imgWaiting').show();
    $.post("post/post_ajaxReport.jsp",
  {
    theParam:seconds
  },function(data) {
    $('#imgWaiting').hide();
    window.location=data;
 });

}

and the following for post_ajaxReport.jsp

<%
 int theParam=myFunctionToConvertStringToInt(request.getParameter("theParam"));
int a=theParam/60;
int b=theParam-a*60;
String query="WAITFOR DELAY '00:"+a+":"+b+"';";
double d=myCustomCodeToRunQuery(query);
String fileName=createReport();
%>
<%=fileName%>

The code worked perfectly up to 100 seconds. But it did not work for more than 100 seconds.

Any ideas?

UPDATE AFTER FEEDBACK

AJAX ( 100- - CloudFlare). AJAX, , IP-. , , , AJAX- ! : " AJAX, 100- -, IP-..."

0
2

- , , . AJAX , Thread, AJAX "", , . .

, , . , .

java ThreadMyReport

public class ThreadMyReport implements Runnable {

    String fileID = "";
    Date dateOfReport = null;

    public ThreadMyReport(Date dateOfReport) {
        this.fileID= "MyReport_" + UUID.randomUUID();
        this.dateOfReport = dateOfReport;
    }

    public void run() {
        int a = ReportMyReport.loadAndSaveMyReport(dateOfReport, fileID);
    }


    public String getFileID() {
        return fileID;
    }
}

ReportMyReport.loadAndSaveMyReport. , fileName .

,

    ThreadMyReport a  = new ThreadMyReport(theDate);
    Thread theThread=new Thread(a);
    theThread.start();
    fileID=a.getFileID();

javascript AJAX , , , .

<SCRIPT language="javascript">


    var myVar;
    myVar=setInterval(function (){
    $.post("post/post_checkReportReady_xml.jsp", {
       generatedReport: '<%=fileID%>'
    }, function(data) {
       if (data.indexOf("produced")>-1) {
           clearInterval(myVar);
           //display report
       }
       if (data.indexOf("failed")>-1) {
           clearInterval(myVar);
       }
    });

}, 1000);
        </SCRIPT>

AJAX :

     <%
    String result="";

    String generatedReport=(request.getParameter("generatedReport"));

    if(!"".equals(generatedReport)) {
        String fileName2="My directory/"+generatedReport+".xlsm"; 
        java.io.File f = new java.io.File(fileName2);
        if(f.exists()) { 
            result="produced";
        }
    }
}

%>
<%=result%>
0

cloudflare html xhr, greycloud , . ...

CloudFlare dns:

  • www 123.123.123.123 = ()
  • ajax 123.123.123.123 = ( DNS)

- ajax.mydomain.com .

, fqdn, , .

function ajaxReport() {
    var seconds = prompt("Please enter how many seconds you want the report to run", "5");
    $('#imgWaiting').show();
    $.post("//ajax.mydomain.com/post/post_ajaxReport.jsp",
  {
    theParam:seconds
  },function(data) {
    $('#imgWaiting').hide();
    window.location=data;
 });
}

IP-. .

0

Source: https://habr.com/ru/post/1648839/


All Articles