2

I have a strange problem with using ajax post requests. I use the request to run an ImageMagick process directly on the command line by using php function exec(). The process takes about a minute, and then responds with some variables. This is working fine, except from one problem. During the execution time I cannot excess other parts of the website that are installed on the same webserver (as if the server is unreachable). When the process finishes, everything works fine again.

I first thought this to be due to an overloaded server. However, when you access the website via another browser, there are no problems, even during the execution time of the process in the other browser. So it looks like the problems has something to do with browsers blocking other requests during the post request.

Could anyone help me out here? What could be the root problem?

4
  • Just want to ask, are you using sessions in your application and how are you handling them
    – kukipei
    Oct 10, 2011 at 10:02
  • I use the php session_start() functionality to check if a user is logged into the application. Along with the userid, the session cookie stores an access token. Every post request sends the userid and access token, and if they match, the command line request is called.
    – Bjorn
    Oct 10, 2011 at 10:17
  • Well this is my opinion and I am not sure but I think that your application locks session file on server so when your start your application again it tries to access same session file and that session file is locked. Again I am not sure...
    – kukipei
    Oct 10, 2011 at 10:24
  • Looks like your on to something here... it probably has to do something with those sessions. If I call up a webpage that doesn't use session_start(), I can load the page without problems...
    – Bjorn
    Oct 10, 2011 at 10:25

1 Answer 1

0

Found the solution! Thanks from the help by kukipei By adding session_write_close(); to the file of the ajax request (after is has read the userid and token), the session file is no longer locked, and all pages are accessible again. Problem was that the session was locked during the whole execution time of the process, which was not necessary, since I only needed the session to read the userid and token. So before calling the ImageMagick operation, I now add session_write_close()

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.