I run a bunch of servers that I monitor on a minutely basis from another server. The relevant bit of code goes like this
$ctx = stream_context_create(array('http'=>array('timeout'=>10)));
try
{
$mei = file_get_contents("https://url/status.php?key=shhh",false,$ctx);
} catch(Exception $e)
{
trigger_error($e->getMessage());
$mei = null;
}
I started providing a stream context when I realized that if one of the monitored servers is down the whole setup stops working and returns a 504, Bad Gateway, error.
Everything good so far. What puzzles me is this - for some reason the 10s timeout is triggering an error message in my Nginx log file but I am unable to catch the exception in my code above. I should mention that this is NOT and error_reporting
issue. I checked my error_reporting
settings and, for good measure, tried with error_reporting(E_ALL)
right at the top.
I could always just stick in an @
prior to file_get_contents
and everything would be fine but this puzzles me - either I need to stop working and spot my mistake here or else there is another issue at work.