balachander_j Posted January 16, 2009 Share Posted January 16, 2009 In my website, I am making an http request to a different server. But sometimes what happens is that the server is down and it takes either too much time to return or it doesn’t return at all. So at the end the “connection timed out” error comes up and because of which my site also becomes slow. Is there a way in PHP in which I can check that if the server is taking too much time, I can end the connection (say after 5 secs) on my own and continue the execution of my site? The idea is that my website should not become slow. I tried using set_time_limit() function but it is not working. Any help would be highly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/141054-help-when-server-is-down/ Share on other sites More sharing options...
thegamer Posted January 16, 2009 Share Posted January 16, 2009 In my website, I am making an http request to a different server. But sometimes what happens is that the server is down and it takes either too much time to return or it doesn’t return at all. So at the end the “connection timed out” error comes up and because of which my site also becomes slow. Is there a way in PHP in which I can check that if the server is taking too much time, I can end the connection (say after 5 secs) on my own and continue the execution of my site? The idea is that my website should not become slow. I tried using set_time_limit() function but it is not working. Any help would be highly appreciated. Hi, have you tried setting the server connection limit in your configuration files Quote Link to comment https://forums.phpfreaks.com/topic/141054-help-when-server-is-down/#findComment-738244 Share on other sites More sharing options...
balachander_j Posted January 16, 2009 Author Share Posted January 16, 2009 In my website, I am making an http request to a different server. But sometimes what happens is that the server is down and it takes either too much time to return or it doesn’t return at all. So at the end the “connection timed out” error comes up and because of which my site also becomes slow. Is there a way in PHP in which I can check that if the server is taking too much time, I can end the connection (say after 5 secs) on my own and continue the execution of my site? The idea is that my website should not become slow. I tried using set_time_limit() function but it is not working. Any help would be highly appreciated. Hi, have you tried setting the server connection limit in your configuration files Do you mean max_execution_time..? If yes, then it is set as the default value i.e., 30. If not, then how to do that? Quote Link to comment https://forums.phpfreaks.com/topic/141054-help-when-server-is-down/#findComment-738252 Share on other sites More sharing options...
thegamer Posted January 16, 2009 Share Posted January 16, 2009 In my website, I am making an http request to a different server. But sometimes what happens is that the server is down and it takes either too much time to return or it doesn’t return at all. So at the end the “connection timed out” error comes up and because of which my site also becomes slow. Is there a way in PHP in which I can check that if the server is taking too much time, I can end the connection (say after 5 secs) on my own and continue the execution of my site? The idea is that my website should not become slow. I tried using set_time_limit() function but it is not working. Any help would be highly appreciated. Hi, have you tried setting the server connection limit in your configuration files ae..? If yes, then it is set as the default value i.e., 30. If not, then how to do that? max excution time can be set by the directive max_execution_time = 10. In xampp\apache\bin\php.ini.Likewise You have to change it in php.ini files in the following folders xampp\php\php4\php.ini xampp\php\php5.ni xampp\php\php.ini Quote Link to comment https://forums.phpfreaks.com/topic/141054-help-when-server-is-down/#findComment-738259 Share on other sites More sharing options...
balachander_j Posted January 16, 2009 Author Share Posted January 16, 2009 max excution time can be set by the directive max_execution_time = 10. In xampp\apache\bin\php.ini.Likewise You have to change it in php.ini files in the following folders xampp\php\php4\php.ini xampp\php\php5.ni xampp\php\php.ini I don't have access to the php.ini file. And even if i manage to change this file, it will affect other parts of the site. It would be very helpful if anyone provide me with some other solution. Quote Link to comment https://forums.phpfreaks.com/topic/141054-help-when-server-is-down/#findComment-738286 Share on other sites More sharing options...
JonnoTheDev Posted January 16, 2009 Share Posted January 16, 2009 How are you making the request. If you are not using CURL then I recommed this as you can set a request time limit. Quote Link to comment https://forums.phpfreaks.com/topic/141054-help-when-server-is-down/#findComment-738288 Share on other sites More sharing options...
balachander_j Posted January 16, 2009 Author Share Posted January 16, 2009 How are you making the request. If you are not using CURL then I recommed this as you can set a request time limit. No i was not using curl. I just read about it. I think its a good idea. Thanks a lot. Quote Link to comment https://forums.phpfreaks.com/topic/141054-help-when-server-is-down/#findComment-738342 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.