2

I am trying to invoke the back-end controller with below POST ajax call

$http({
 url: 'WS/datagen/' + userID + '/' + rows+'/'+validatePrimaryKey,
 method: "POST",
 timeout: 300000,
 data: $scope.cnentity
}).then(function(response) {
  // success
  $rootScope.loading = false;
  if (response.data == true) {
  $rootScope.myAlertElm.html('<span style="color:Green;"><strong>Data          Generated Successfully !! \n Please click "Check Data availability"  again</strong><span>');
 } 
 else {
  $rootScope.dgAlertElm.html('<span style="color:Red; "><strong>Data generation cannot be done for conditions containing primary key!</strong><span>');
  return false;
 }
console.log("hitting the query service");
}, 
function(response) { // optional
        // failed
        console.log("Failure");
        $scope.delta = ( ( new Date() ).getTime() startedAt.getTime() );
        console.log($scope.delta);
});

Then the response is getting timed out and resulting in this message.

Failure<HEAD><TITLE>Connection Timed Out</TITLE></HEAD>
<BODY BGCOLOR="white" FGCOLOR="black"><H1>Connection Timed Out</H1><HR>
<FONT FACE="Helvetica,Arial"><B>
Description: Connection Timed Out</B></FONT>
<HR>
<!-- default "Connection Timed Out" response (504) -->
</BODY>

This is happening randomly when multiple users are trying to invoke this program. The back-end program is synchronized and multi-threaded. It executes user by user in a sequence and this may take 3 minutes for each user request and sometimes more than that. During this wait, timeout is occurring.

I have tried to increase apache timeout and ajax http timeout but it didnt solve anything. How to avoid or increase this timeout? Will long-polling/websocket help this? If yes, how to implement a post call?

Jesh
  • 63
  • 3
  • 9

0 Answers0