Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

fsockopen(): unable to connect to localhost and slow file_get_contents

Status
Not open for further replies.

Phara0h

Programmer
Aug 1, 2004
18
0
0
NO
Whenever I start a session before I call file_get_contents PHP crashes. It is not able to connect to any other site.

I am not able to use fsockopen to connect to my smtp either.

Using fsockopen to connect to smtp gives me:
Warning: fsockopen(): unable to connect to localhost:25

When running the example below I get the results both when I include the session_start AND not. But when including start_session the server uses 30 to 60 seconds to open the page. (When no session_start it uses 1 second)

Not including session_start() in the top of the examples makes the functions work.

My example for file_get_contents looks like this:

<?php
session_start();
$strContent = file_get_contents('
?>
 
I dunno what to say. When I run a modified version of your code:

Code:
<?php
session_start();
$strContent = file_get_contents('[URL unfurl="true"]http://www.vg.no');[/URL]
$fh = fopen ('test_foo.txt', 'w');
fputs ($fh, $strContent);
fclose($fh);
?>

the script finishes its runs in somewhere between 2 and 3 seconds and the file "test_foo.txt" contains the HTML of the specified site.

What version of PHP are you running on what platform?



Want the best answers? Ask the best questions! TANSTAAFL!
 
It's hard to say what the problem is. Have you tried running the session-enabled script via the command-line?

I can state for a fact that you are running a version of PHP that was released in November 2003. There have been an awful lot of improvements and bugfixes in the intervening 3 and a half years.

I'm not sure what's going on. When I use telnet on port 80 to fetch both pages, it takes forever before I even get a server response on the session-enabled page.


You've said you're running PHP 4.3.4, but your server says you're running 4.3.11. I assume you're getting your information from a phpinfo() script. I'm wondering if there's something wrong between your PHP installation and your web server.



Want the best answers? Ask the best questions! TANSTAAFL!
 
This is what I get when running the session_enabled file from ssh.

box1:/ # php sleipnir.php

Fatal error: Call to undefined function: session_start() in / on line 4


The techs working on my server yesterday swapped a .so file to upgrade the php-installation. My phpinfo <-- I got this from cli since it does not work in web mode.

The phpinfo says 4.3.4 and it says in the configure line --disable-session ... I have a script using session, and session is working as it should..
 
The techs working on my server yesterday swapped a .so file to upgrade the php-installation.

It sounds to me like the techs broke something.

As a good general rule, I have never had success swapping out PHP .so files. Since I install by compiling the source tarball, I've always had to do an upgrade by compiling and installing the new version.



Want the best answers? Ask the best questions! TANSTAAFL!
 
I am running SLES9, so compiling php is really not fun ;) ... I am not really best at compiling.

But I have a viritual server on the same machine, so if I had some way of copying the os to the other viritual machine I could do a test upgrade on that one.

Do you know of a way of getting the whole os from one server to another?
 
Well what I have run into earlyer is that I need to compile apache2 too in order to make the php a php-module.

I am really not that skilled in compiling php :(
 
Yes, there can be lots of software which needs to be compiled and installed before PHP. But you've got odd errors and it sounds like someone's been tinkering.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top