We have a problem on Debian server and PHP version 4.4.4-8+etch6. In this script (it is full script, not just part of code):
mysql_connect('localhost', 'user', 'pass');
session_start();
$h = fopen('http://www.google.com/robots.txt', 'r');
var_dump(fread($h, 40));
If I comment out mysql_connect, it works. If i comment out session_start, it works.
If mysql_connect failed (bad user and password) fopen works too. But with both, fopen failed. So it is not related to DNS lookup.
There is a result
Warning: fopen(http://www.google.com/robots.txt) [function.fopen]: failed to open stream: HTTP request failed! in /var/www/web4/rychtarka.cz/rychtarka.cz/test.php on line 9
Warning: fread(): supplied argument is not a valid stream resource in /var/www/web4/rychtarka.cz/rychtarka.cz/test.php on line 10
bool(false)
I think, there is some resources limit in system, file descriptors or something. Our server administrator told us, it is skript error. Can you please point me to debian system change to repair.
Thank you for any advice.
Finally (after 3 days) we fixed the error. We traced it using 'php -f test.php' which pointed to Apache's limit on max open files.
We raised number via ulimit from 1024 to 8k and after a restart everything worked great.
Related
My PHP program access a website which is very slow to open, therefore I get a warning message:
Warning: file_get_contents(http://www.example.com): failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\xampp\htdocs\mezi.php on line 155.
Line 155 code: $html = file_get_contents('http://www.example.com');
My question is: how to increase time allowed to wait for slow website? I have already increased allowed execution time by adding set_time_limit(100); to my code. But this does not help.
This is actually a socket session that's being created behind the scenes, therefore the correct value in php.ini would actually be
default_socket_timeout
This page of my site is taking 1 minute to load. Then I got this error:
"Warning:
simplexml_load_file(http://www.cpalead.com/dashboard/reports/campaign_rss.php?id=MyID&geoip=MyIP&show=6&offer_type=pinsubmit):
failed to open stream: Connection timed out in ../pass/pass.php on
line 125 Warning: simplexml_load_file()"
My code:
$call_url = 'http://www.cpalead.com/dashboard/reports/campaign_rss.php?id='.$user_id.'&geoip='.$ip.'&show=6'.'&offer_type=pinsubmit';
if($xml = simplexml_load_file($call_url, "SimpleXMLElement", LIBXML_NOCDATA))
What I've tried to fix that and didn't work:
Switch allow_url_fopen to ON in php.ini of my hosting.
set the max time out to 300 second instead of 120.
It's because the website has blocked your server, after they got too many requests from your server.
There is no solution until they unblock you voluntarily or upon your request (I am not sure they have a way to do that). But if you can move to another server, that can work, until they block that server also!
Golden rule is "Don't make too many requests to any specific site unless they have allowed you to do that by terms."
I've got a fairly simple cron job that pulls down some files from an FTP server - none of the files are particularly large, but I'm constantly getting the following:
Connected to voip.colefabrics.com, for user colefabrics\absolute
Warning: ftp_get(): Opening BINARY mode data connection. in /home/www/colefabrics.com/httpdocs/libs/classes/class.ftpObj.php on line 56
There was a problem while downloading website/items.csv
Attempt 2:
Connected to voip.colefabrics.com, for user colefabrics\absolute
Warning: ftp_get(): Opening BINARY mode data connection. in /home/www/colefabrics.com/httpdocs/libs/classes/class.ftpObj.php on line 56
There was a problem while downloading website/items.csv
...snip...
I've been through all the other posts relating to this, tried to enforce passive mode, increased the timeout, but nothing is working.
Does anyone know what might be causing this, and what I can do to try and resolve it?
To confirm, it's working fine via a 'normal' FTP client, it's only via PHP that I have a problem.
I run a shopping site and am trying to save a copy of this remote gif image to my server as jpg.
$i='http://www.medexsupply.com/images/RO1R910C.GIF';
$imagejpg = imagecreatefromgif($i);
and it gives following errors :
Warning: imagecreatefromgif(): Couldn't resolve host name in /home/xxxxx/public_html/xxxxxxx/file.php on line 46
Warning: imagecreatefromgif(http://www.medexsupply.com/images/RO1R910C.GIF): failed to open stream: operation failed in /home/xxxxx/public_html/xxxxxxx/file.php on line 46
on line 46, the code is
$imagejpg = imagecreatefromgif($i);
I have dedicated server with 128MB memory limit for php scripts.
allow_url_fopen is on.
I can modify any setting on my server.
I could copy thousands of other remote images but not this image and images from some other sites.
Can someone help.
Please reply if you would like to know more information.
Thank you
There is a DNS issue with your domain, which explains the "could not resolve host" message.
From my browser, I can access your images. Yet from a different machine, I get:
$ dig www.medexsupply.com
; <<>> DiG 9.7.3 <<>> www.medexsupply.com
;; global options: +cmd
;; connection timed out; no servers could be reached
At this point in time, it could be possible that Sandy is the cause, as I see you are hosted with Rackspace in New York and, from the machine that gave the error above, I cannot ping their nameservers.
A URL can be used as a filename with this function "imagecreatefromgif " if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename and List of Supported Protocols/Wrappers for a list of supported URL protocols.
I have following code:
$fh=fopen($api,"r");
$theData = fgets($fh);
echo $theData;
This throws the error as :
Warning: fopen(http://xxxxxx.xxxxxxxx.com:8080) [function.fopen]: failed to open stream: Connection refused in /home/xxxx/public_html/xxxx/index.php on line 18
Warning: fgets(): supplied argument is not a valid stream resource in /home/xxxx/public_html/xxxx/index.php on line 19
What is the solution for this?
Your file did not open as you intended. Check the value of $api and be sure the file name is in the current working directory, or the entire path to the file.
Since it is a remote system on :8080, be sure the port is open to the public. This is typically a value reserved for localhost (ie: the webserver is only a webserver to that computer, no one else's) and wouldn't be accessible to you. If the url you are opening is the same computer you are using, navigate to the file using local folders instead.