fsockopen error connection timed out
pkawadkar said 2 years, 5 months ago:
I am getting error as connection timed out error code -110 while using @fsockopen. I am using drupal and for sending http request I am using drupal_http_request. The same code is working fine with apache2 web server from my PC and able to send http request. So looks like something from godaddy server is blocking me from sending http request. What should be possible reasons? How do I fix it?
Appologies if this is already discussed and answered but I could not find anything when I searched for it.
DaveD said 2 years, 5 months ago:
@pkawadkar
A timeout doesn’t mean that the request is being blocked, but that the request has run too long. Are you trying to request a large amount of data? The default value for default_socket_timeout is 60-seconds and this can’t be changed on our Shared plans. If you are trying to request a large amount of data, you may need to break it into smaller sections and run multiple requests. However, the best option would just be to reduce the amount of data you are requesting.
Hope this helps!
pkawadkar said 2 years, 5 months ago:
What is limit on data? I am calling HTTP APIs provided by other server to send messages. Data I am sending should be around 200-220 characters (140+ metadata ). I think data writing will come into picture once connection is open. It looks like that fsockopen is failing with error as connection timed out. It is not able to open connection with that server.
chrisg said 2 years, 5 months ago:
@pkawadkar,
There is no limit on data that would be causing the specific issues you have described. Especially for the amount of content you have described attempting to retrieve from an API.
The only limit that should be causing this sort of error is the timeout settings previously described by @DaveD.
Without having direct access to your account to see how the scripts are configured, you may be running multiple functions at the same time that require more time to be executed before the data can be called. The Max Execution time of your hosting account is a setting that you have complete control over in a PHP environment. If you need to increase this setting to allow more time for your functions to completed, you can modify this through a custom php.ini (for PHP 4) or php5.ini (for PHP 5).
If you are still encountering a time out after attempting to increase your Max Execution time, I would suggest contacting our Live support directly so we can investigate this from within your account further.
Our Live Support Department is available 24/7 and can be reached at:
http://support.godaddy.com/support
Christopher G.
pkawadkar said 2 years, 5 months ago:
Thanks Dave D and christopher for your suggestions but that does not solve my problem.
I am using ini_set(default_socket_timeout, 1200), I am also checking it in next function with ini_get and getting value as 1200.
usewide said 2 years, 5 months ago:
check the request header, even with GD free hosting plan, an amount of data of 12Mb can be transfered without any problem.
chrisg said 2 years, 5 months ago:
@pkawadkar,
As I previously stated, you would want to try modifying your ‘max_execution_time’ settings within php.ini. Modification of your ‘default_socket_timeout’ would not be the cause of this issue, plus it cannot be modified within our shared hosting environment.
If you have not tried to modify the ‘max_execution_time’, then you scripts are attempting to complete running at the default setting of 30 seconds, which may likely be the cause of your timeouts.
Again, if modifying your ‘max_execution_time’ does not resolve the time out errors, you will need to contact our Live Support for further assistance.
Christopher G.
pkawadkar said 2 years, 5 months ago:
I changed max_execution_time to 60 and also changed allow_url_fopen= ON but I am still getting error connection timed out. fsockopen is failing. Even I tried loading php.ini from my local PC. Will php.ini run automatically whenever php script get executed or I need to do something to run it. How do Irun it then on server?
Another problem I am facing is that whenever site is very slow , I get internal server error when I am trying to create a file of size 33KB. Script fetches data from database and generate a csv file.
Not sure both problems are related to
marcelocecin said 1 year ago:
var $server = ‘messenger.hotmail.com’;
var $port = 1863;
$fp = @fsockopen($server, $port, $errno, $errstr, 5);
this will work ?
2 min expected wait time