Page 1 of 1

advice on debugging a session hang problem please

Posted: Fri Nov 03, 2006 3:51 am
by lol
I have a problem with a hosted site that is experiencing very intermittent page hangs. I cannot reproduce the problem except by accident. When the problem occurs, the symptoms are that any PHP session enabled page will not load, but any non session enabled page (i.e. the help pages) will load OK. Closing the ie window and opening a new one fixes the problem. If you wait long enough (a long time, I have not managed to measure this accurately yet), the problem will "unhang" itself.

I have spoken to the isp, who have given a std "can't reproduce it" response. As far as I can tell, the relevant session handling code is simple and correctly implemented. I've googled for similar problems and haven't been able to find anything of much use.

As a programmer relatively new to PHP, I could do with a "sanity check" please? How would you debug this problem?

Many thanks to anyone who has time to share advice.

Posted: Fri Nov 03, 2006 11:34 am
by aaronhall
It sounds like your host is causing the trouble. I was with a web host whose servers would go down sporadically, and the symptoms were just as you described. If you can move, aplus.net is the best I've found so far.

Posted: Fri Nov 03, 2006 12:01 pm
by RobertGonzalez
Can you post some of the code, specifically where the call to session_start() is?

Posted: Sat Nov 04, 2006 5:13 am
by lol
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


The session_start() is always at the top of the page, i.e.

Code: Select all

<? session_start(); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
There is output buffering enabled on a couple of pages, although these are not always the ones that hang. These pages start:

Code: Select all

<?
ob_start();
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
The CW seems to be to rely on the automatic buffer flush, however I've tested the site extensively with and without:

Code: Select all

<?php
  while (@ob_end_flush());
?>
at the end of the page and that doesn't make any difference to the hang problem.

Does that clarify it at all Everah?


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sat Nov 04, 2006 8:48 am
by RobertGonzalez
There are a soupl of suggestions I would make. Based on what you are saying about your page load hangs, I would guess that there is either a session write problem on the server itself or a script execution timeout problem taking place somewhere (perhaps with a database connection). First thing I would do is raise the level of error_reporting in your script and turn display errors on (for debugging only). Somthing like this at the top of your session'ed pages...

Code: Select all

<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
?>
Then I would run the pages again to see if there are any not fatal errors being thrown by the script (let the page load for more than 30 seconds to allow for max execution time errors). If you still get a hang or a blank page, then you need to ask your host for a copy of your error logs for the last day to see if the server is seeing something that PHP is not throwing out.

Posted: Sat Nov 04, 2006 10:23 am
by lol
thanks for your suggestions & I'll try them shortly.