Jump to content

Ajax calls are freezing my browser on my localhost Apache install on windows XP.


ghostcoder

Recommended Posts

Ok so I have an Ajax chat app that I've created. Works great.

 

However, when running it locally on my Windows XP box with Apache installed, it freezes up over time, like in 30 minutes or something. It's very odd. I'm thinking it might be MySQL related, but it is definitely Apache related some of the time. The trick to getting it going again is switching Apache off and back on again. However, I'm getting tired of doing this over and over again.

 

Any ideas ?

Link to comment
Share on other sites

Well, post your code. What exactly is freezing up? The computer, the web page, or your browser?

 

If you use Firefox, you can install the Firebug add-on. It will allow you to actually watch your ajax calls as they happen and it is a great troubleshooting tool.

Link to comment
Share on other sites

Are you doing a lot of session management? Or any at all, within the ajax calls?

 

What I have noticed is that if you open a session with an ajax call sometimes  said call will nab up all the write permissions to that session and never free it up. Then any future PHP files will lock up waiting to grab said session for reading or writing.

 

It is best to close the write permissions when you are done writing to a session, to avoid this.

 

session_write_close();

 

will do the trick.

 

If you are opening the session just to read from it, follow it up with a write_close immediately. If not, close as soon as you are done writing.

Link to comment
Share on other sites

Thanks F1Fan, I'll check out the Firebug. I already use the web developer add on and it's awesome. Although it hasn't given me any hints here.

 

Ajlisowski, thanks for the feeback. I have not been doing any session_write_close(); calls. I do a session_start() and that's about it.  There is a  place where I call session_destroy, but it has only been in certain cases.  I will try session_write_close() and see what happens!

 

I'll report back when I find out anything new... thanks again.

Link to comment
Share on other sites

I dont believe you need to actually write to the session for it to lock up. I could be wrong there though. I think that when you open a session it grabs write permission until you either close the session or let go of write permission. Thus, even if you arent writing, the ajax call could nab the permission, never technically let it go and then when your next page tries to get it as well, it locks up.

 

Your issue may very well be something else entirely. I just beat my head against a wall a few months ago with the same sympthoms as your problem and thats what it turned out to be.

Link to comment
Share on other sites

I've worked on 3 different AJAX run chats, offline and online.

 

Only time i've experienced the browser freezing up was when javascript/AJAX was the cause.

 

If you got page Timers.  Test if its the cause by changing the interval between execution.  I've only had a timer set to 1 second repeat and my PC usage was at 100% the whole time, and with the chat going and the more messages appeared on the chat, the more laggy my PC got.

 

If you got a function that process alot of data repeatively, related to the timer thingy again, space it out or remove this function tempary to test if the function could be the problem.

 

Also i dont think its your PC / Server / PHP / MYSQL thats the problem.

 

It is also possibly smart to test your AJAX scripts.  I suggest you post that information up here and see if anyone notice a problem with AJAX script that could be slightly related to your problem.

Link to comment
Share on other sites

Quick update. I'm still testing things, but since I added session_write_close(); to my php scripts being called via AJAX, I've not had a single browser freeze up!

 

* knocks on wood *

 

Thanks for the tip ajlisowski, and thanks for the other feedback as well. I'll report back here if things change.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.