| View previous topic :: View next topic |
| Author |
Message |
Anonymous Guest
|
Posted: Tue Feb 06, 2007 3:35 pm Post subject: Changed servers, PHPfopen stopped working to open stat relay |
|
|
Hello all,
I've also posted this inquiry at a couple of PHP web sites, but some of the behavior suggests it may be an Icecast thing, so I toss it to y'all.
I'm presently running Icecast 2.3.0 on a Windows Server 2003 system, and I have a script that accesses it from a web hosting server at HostMonster.
I have a PHP script that reads an XML file and parses it so it can be searched and the artist and song information extracted from it. It starts by opening a connection to the stats relay page with the PHP fopen function. On our previous server, it worked perfectly. We changed to another server at the same web hosting service. Now the connection times out. As far as I can gather, the two servers are identical other than the IP address. I cannot put my finger on any differences that might cause fopen to work on one server but time out on the other server.
The code that makes the connection is:
| Code: |
$server = "66.139.73.72:8000";
$user = "username";
$passw = "password";
$mountpoint = "/cyg1_hi";
$fp = fopen("http://$user:$passw@$server/admin/stats","r")
or die("Error reading Icecast data from $server."); |
The error message that comes out now is:
| Code: |
Warning: fopen(http://...@66.139.73.72:8000/admin/stats) [function.fopen]: failed to open stream: Connection timed out in /home/cygnusra/public_html/index.php on line 395
Error reading Icecast data from 66.139.73.72:8000. |
I'm stumped. The php.ini file is identical on both accounts, and as far as I can tell the output of phpinfo() is identical on both servers. As far as I can detect (granted, my experience with Windows Server is limited) there is no IP address blocking on the Icecast server that would cause it to accept connections from the old server but not from the new server.
Now, the only hint I've discovered is that if I try to open another source (such as the XML of my podcast RSS file) then fopen works fine. So what I'm wondering is, is Icecast perhaps seeing log-ins on the stat relay from two different IP addresses and for some reason not wanting to acknowledge the other IP address, perhaps for security reasons? I can't find anything in the icecast.xml file that might suggest it's doing this.
Can anyone think of anything I haven't checked that could cause this inconsistency?
David V |
|
| Back to top |
|
 |
Anonymous Guest
|
Posted: Tue Feb 06, 2007 4:49 pm Post subject: I'm gonna guess here ... |
|
|
Let me ask you this - have you tried opening another remote url with fopen that is *also password protected* and would require the user/password? You mention that you can open an RSS feed but I'm buessing that one isn't behind any authentication. So I'm guessing perhaps the version of fopen() on the new host is borked with repsect to this somehow
In that same vein - to test, copy an admin/stats output to a non password protected file somewhere and try fopen'ing that. If it works, you know it's something to do with that authentication. Consider using wget or curl or something instead of fopen(), if fopen is indeed wonky.
-bhance |
|
| Back to top |
|
 |
Anonymous Guest
|
Posted: Tue Feb 06, 2007 5:41 pm Post subject: |
|
|
That is an excellent point....I have not yet set up that kind of test. It's worth trying.
I looked at using curl, but I was confused as to how to use it in conjunction with the code I have. Can you point me to any code examples of using curl to read the stats XML?
Thanks for that idea. I knew posting here was a good idea.  |
|
| Back to top |
|
 |
Anonymous Guest
|
Posted: Tue Feb 06, 2007 6:53 pm Post subject: Well ... |
|
|
... if all you're looking to do is parse, manipulate, and display XML somewhere, Magpie (http://magpierss.sourceforge.net/) might help. However, I just spent ten minutes messing around with a sample /admin/stats XML output and magpie doesn't wanna parse it... so ...
Assuming Curl's installed and part of your php setup:
<?
// Could also use the username:password@syntax here
$pageurl = 'http://example.com/admin/stats';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_URL, $pageurl );
$html = curl_exec ( $ch );
curl_close($ch);
?>
<P>
Here it is:
<?=$html?>
You'll still have to parse and deal with the $html variable, but you get the idea. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2002 phpBB Group subRebel style by ktauber
|