Reputation: 1911
My CasperJS
script calls via jQuery
an PHP script
. Problem is, that the PHP script takes around 70 sec to excute, but somehow CasperJS or jQuery are canceling the request after around 30 sec and throw the error: Error: NETWORK_ERR: XMLHttpRequest Exception 101
.
Code to call the PHP script:
var result = casper.evaluate(function(){
$.ajaxSetup({'async':false});
var result = $.get('http://localhost/full.php', function() {} );
return result;
});
I tried the following solutions:
// For CasperJS:
pageSettings: {
timeout: 999999999
}
// For jQuery
$.ajaxSetup({'timeout':999999999});
Also I made sure that the executed PHP script is not the cause for the error (I made a test-script with all used functions, which only takes some seconds to execute. This works fine).
I read that jQuery has no timeout by default and that CasperJS throws an error, when a timeout occurs. But somehow it must be timeout error, because it always occurs after around 30 sec. (btw.. the PHP script uses set_time_limit(0);
)
Thanks for any suggestions!
Upvotes: 1
Views: 1703
Reputation: 24558
Also I made sure that the executed PHP script is not the cause for the error (I made a test-script with all used functions, which only takes some seconds to execute. This works fine).
It's maybe the problem. Did you tried when you script when it takes 70 s ? Php has also a maximum execution time setting as said here. By default, it's 30 secs. Try to test in the same scenario.
Jsut for futures references, the default Jquery Ajax Timeout is 0 (technically it's undefined, but behaves as 0). This means no timeout in jQuery itself... You could specify one via $.ajax ({timeout: XXXX })
or $.ajaxSetup ({timeout: XXXX })
. The complete callback contains a string categorizing the status of the request ("success", "notmodified", "error", "timeout", "abort", or "parsererror").
There is also two timeouts in casperJs : timeout and steptimeout. There are also two callback ontimeout
and on steptimout
that are executed when script/step execution time exceeds these limits.
Upvotes: 2