Page 1 of 1

Previous Request Not Completed

Posted: Fri Jun 19, 2015 5:05 pm
by pkmittal
Hi, When my program use many Post Command simultaneously then I get the error message "Previous Request Not completed" .

Is there any way so that I can check if any previous request is under process? and then we call Post only when previous request is completed.?

Please let me know

Thanks
Cheers
pkm

Re: Previous Request Not Completed

Posted: Fri Jun 19, 2015 9:55 pm
by dave.kilroy
hi - how about setting a 'flag' (a local or global variable, or a custom property) when initiating a post, and only when you get something back from the server to indicate it has completed (or an error message which you can handle) do you change the 'flag' back to clear - and each time you initiate a post you check for the value of this 'flag' and only proceed if it's clear...

Re: Previous Request Not Completed

Posted: Sat Jun 20, 2015 4:02 am
by pkmittal
Thank. I am sending POST request every 3 seconds and another function is also sending post request every 2 seconds. Should I use wait statement before sending the request? or should I put it in loop so that send request only when the global flag is clear ?

Is there no other predefined global/local variable which can tell if it is the right time to send the Post Request?

Re: Previous Request Not Completed

Posted: Sat Jun 20, 2015 7:41 am
by pkmittal
Hi,
My Program is calling
1) getLatestUserMove every 5 second so that It is sending Multiple Post Request every 5 second.
2) postUserMove it has to send successful post request only once, when user make some move. If the post request is not completed in the first function then post request in second function throws the error. How can we use wait command or flag so that post request in second function works well? We just need only 1 post request in second function but I am using the repeat loop to try from 1 to 10 so that at least one is successful.. Please let me know what can I change so that it gives guarantee that post in second function is successful.

Code: Select all

function getLatestUserMove
   global canPost   

   put false into canPost
   post postString to URL (urlString)
   
   if it is empty
   then
      put the result into returnText
   else
      put true into canPost
      put it into returnText 
      replace numToChar(13) with empty in returnText
   end if
   
   return returnText
   
end getLatestUserMove


Code: Select all

function postUserMove

   global canPost
   
   
   repeat with X =1 to 10
      
      post postString to URL (urlString)
      
      if it is empty
      then
         put the result into returnText
         put "result " & returnText & cr after field "debug"
      else
         put it into returnText 
         replace numToChar(13) with empty in returnText
      end if
      
      if returnText  contains "previous" then
         #wait for 1 second    
      else 
         exit repeat
      end if
   end repeat
   
   
   return returnText 
   
end postUserMove

Re: Previous Request Not Completed

Posted: Mon Jun 22, 2015 10:27 am
by dave.kilroy
hi Pradeep - ok i see what you are doing with the returned error messages ... at first when I looked through my own code examples for POST I thought I would have lots, but it turns out I use PUT or GET nearly all the time...

How are you calling your various functions that do POSTing? I ask this because in a thread on the use-list Trevor DeVore says that POST with 'send-in-time' can effectively result in them becoming non-blocking http://runtime-revolution.278305.n4.nab ... l#a4693240 - assuming you are using 'send-in-time', perhaps if you could set up your 5-second loop in a different way? Or find some way to abstract it far enough away from the actual POST that it remains blocking?

You may find something of use in this thread http://forums.runrev.com/viewtopic.php? ... 62#p100062 where Simon (and John Craig in particular) do multiple, non-blocking file uploads using POST) - so it seems to me that Trevor is right and the most likely culprit is 'send-in-time'

Dave