1

I am created a AngularJs Post request.The request contain a long process take more than 2 minutes for perform that.But my angular request return null error after 15 seconds.request perfectly working and no error.But angular request time out with in 15 seconds

 $http.post('/api/evaluateOmrExamination',{exam_id:$scope.curExam.id})
            .success(function(data,status,headers,config){
                $scope.showProgress=false;
                ngNotify.config({
                    theme: 'pure',
                    position: 'top',
                    duration: 3000,
                    type: 'info',
                    sticky: false,
                    button: true,
                    html: false
                });

                ngNotify.set('Evaluate Examination Completed Successfully');

                $scope.errorLists=data;
            }).error(function(data,status,headers,config){
                console.log(data);
                //$scope.showProgress=false;
            });

I am also set time out in angular but no use.

 app.config(['$httpProvider', function($httpProvider) {
    $httpProvider.defaults.timeout = 10000000;
 }]);

I need your suggestions

5
  • what's your api server? apache? Commented Feb 17, 2018 at 8:50
  • yes.LAMP Server Commented Feb 17, 2018 at 9:51
  • LAMP or Wamp server?! Commented Feb 17, 2018 at 9:53
  • in your localhost you have php.ini and you can change max_execution_time, also you can change it in .htaccess Commented Feb 17, 2018 at 9:58
  • i refer increase-max-execution Commented Feb 17, 2018 at 10:00

2 Answers 2

1

Short term fix is to increase your server's timeout (this is not a client / Angular issue). You say you're using LAMP, so you must configure PHP's max_execution_time property in php.ini to a larger value. You may also need to configure Apache's timeout in httpd.conf.

Long term fix, the request could return immediately (i.e. not 2 minutes or even 15 seconds later). This doesn't mean the job is done, just that the request to perform the job is done. Then you can ping your server every X seconds to see if the job is complete, and then get the data to display to the user. It seems like more work, and it may take a little more time, but I've found that it can be easier to develop and debug this way instead of having single monolithic requests that do a lot of work. In addition to being a better user experience :)

Sign up to request clarification or add additional context in comments.

Comments

0

There are some good recommendations here.

app.factory('timeoutHttpIntercept', function ($rootScope, $q) {
    return {
        'request': function(config) {
            config.timeout = 10000000;
            return config;
         }
    };
});

And in your config:

$httpProvider.interceptors.push('timeoutHttpIntercept');

2 Comments

still same problem exist
the problem not solved in the client ! it's server configs i talk about in the comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.