ghostcoder Posted May 22, 2010 Share Posted May 22, 2010 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 ? Quote Link to comment Share on other sites More sharing options...
F1Fan Posted May 23, 2010 Share Posted May 23, 2010 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. Quote Link to comment Share on other sites More sharing options...
ajlisowski Posted May 24, 2010 Share Posted May 24, 2010 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. Quote Link to comment Share on other sites More sharing options...
ghostcoder Posted May 27, 2010 Author Share Posted May 27, 2010 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. Quote Link to comment Share on other sites More sharing options...
ajlisowski Posted May 27, 2010 Share Posted May 27, 2010 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. Quote Link to comment Share on other sites More sharing options...
Ang3l0fDeath Posted May 27, 2010 Share Posted May 27, 2010 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. Quote Link to comment Share on other sites More sharing options...
ghostcoder Posted May 29, 2010 Author Share Posted May 29, 2010 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.