|
|
#1 |
|
Junior Member
Join Date: Feb 2005
Posts: 10
|
Cannot connect with php to parse xml
I am using shoutcast, my home pc, cable modem, linksys router to stream to my webpage. The stream is up and available to the public, all indications are that the port is open, I can login to admin.cgi, I can view the xml, hear the stream, visitors can hear the stream, everything seems normal, yet I am unable to connect from my website using php.
<?php $myip = "ip goes here"; $myport = "port goes here"; $conn = @fsockopen($myip, $myport, $errno, $errstr, 1); if(!$conn) { echo "$errstr - No connection"; } else { echo "Success"; } ?> Yes, I did insert the exact ip and port the server is using. The same ip and port I am able to admin on. I am trying to retrieve the stats xml so I can parse it with php, but cannot get a connection from my website. Is my router interfering, or is my ISP blocking the request? I used http://www.radiotoolbox.com/online_t...ntheygetin.php to test the port, and it says the port is open and the server exists. I am running out of ideas. Anyone have any ideas? I've looked all over the place, but have not found any answers. Certainly someone out there has had the same problem, huh? I know there are drawbacks to using the home pc as a server, is this one of them? Any help is appreciated. |
|
|
|
|
|
#2 |
|
Junior Member
|
PHP Code:
|
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Feb 2005
Posts: 10
|
Thanks for your response. Unfortunately, I had already tried that. I am thinking it is not a php coding error. PHP will return the same result either way you write it. Apparently, php doesn't seem to be too picky about the syntax in this case. I usually go for the "Readers Digest" version if it works because it's less typing and less reading.
Lazy
|
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Feb 2005
Posts: 10
|
Can't anyone answer this question for me?
|
|
|
|
|
|
#5 |
|
Major Dude
|
Try setting a higher value for the timeout argument of fsockopen(), for example:
fsockopen($myip, $myport, $errno, $errstr, 10); Also, remove the '@' in front of the function call so you can see if there's any warning. Words are very unnecessary, they can only do harm, so enjoy the silence - Depeche Mode Firemonger Project: Help spread Firefox |
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Feb 2005
Posts: 10
|
Thanks for the reply.
I had already tried that also. I have tried a number of different ways to code the php for this, but I don't think that is the problem. It's probably the router or the ISP, but I am just guessing. Thanks again. |
|
|
|
|
|
#7 |
|
Major Dude
|
Nah.. if people can connect to your stream, then the script will connect with no probs. But the host where you run the script [your web server] could be blocking ports. You can try setting your DNAS port base to some well-known port [80, 21, 110] Anyway, you should get a PHP warning telling you what's going on, post the URL of your DNAS to test that code from my host.
Words are very unnecessary, they can only do harm, so enjoy the silence - Depeche Mode Firemonger Project: Help spread Firefox |
|
|
|
|
|
#8 |
|
Moderator Alumni
Join Date: May 2000
Location: Next Door
Posts: 8,888
|
likely it is the webserver, many cheap or paranoid hosts have really crappy php installations, buyer beware.
-Jay | Radio Toolbox.com |
|
|
|
|
|
#9 |
|
Junior Member
Join Date: Feb 2005
Posts: 10
|
I guess I assumed that since I haven't had a problem with any other PHP functionality, my host wasn't the problem.
Here is the stream address http://68.1.93.201:7000/listen.pls Thanks for the assistance. |
|
|
|
|
|
#10 |
|
Major Dude
|
I've tested that code from my local web server and from another host and it works just fine. Here's is the link to that code pointing to your DNAS, as you can see the prob is with your web server.
http://dm101.vaio-hosting.com/test.php Words are very unnecessary, they can only do harm, so enjoy the silence - Depeche Mode Firemonger Project: Help spread Firefox |
|
|
|
|
|
#11 |
|
Junior Member
Join Date: Feb 2005
Posts: 10
|
Thank you so much for your help. Now, if my host is as helpful, I'll be in good shape!
|
|
|
|
|
|
#12 |
|
Junior Member
Join Date: Feb 2005
Posts: 10
|
No response from the host, but I found an opening by changing ports.
I switched the DNAS to port 20 and switched port forwarding to 20 - 21 range. I get a connection with php on port 21, but not port 20. The admin and stream are working on port 20. I thought this was sorta weird, but hey, whatever works. Maybe this will help someone else if they ever have this problem in the future. Thanks for the help everyone! |
|
|
|
|
|
#13 |
|
Major Dude
|
That's because they won't block some well known ports, that's a good way to probe that they are actually blocking ports. If you use a paid host, ask them to open the port base of your DNAS, they should do it.
Words are very unnecessary, they can only do harm, so enjoy the silence - Depeche Mode Firemonger Project: Help spread Firefox |
|
|
|
|
|
#14 |
|
Junior Member
Join Date: Feb 2005
Posts: 10
|
Yeah, I'll have to do that because I just figured out that even though I can determine if the server is active on port 21 using php, I still cannot retrieve the xml file because it is only accessible on port 20. Ugh! The php has to be able to work on the same exact port in order to be able process the file request.
|
|
|
|
|
|
#15 | |
|
Junior Member
|
I keep getting this error...
Quote:
PHP Code:
|
|
|
|
|
|
|
#16 |
|
Junior Member
Join Date: Feb 2005
Posts: 10
|
Remove fpassthru($conn); and see if you get the same result. Just a hunch.
|
|
|
|
|
|
#17 | |
|
Major Dude
|
Quote:
@NumbCore: you get that warning because the errno and errstr arguments of fsockopen() are being passed by reference and as the warning says, that has been deprecated in newer versions of PHP. Just remove the reference operator '&' in front of those arguments. Words are very unnecessary, they can only do harm, so enjoy the silence - Depeche Mode Firemonger Project: Help spread Firefox |
|
|
|
|
|
|
#18 | |
|
Junior Member
Join Date: Feb 2005
Posts: 10
|
Quote:
The script connects on port 21 and returns true, but will not retrieve the xml (or even 7.html) on that port. It appears the xml can only be gotten on port 20 which is the port the DNAS is running on, but php will not connect to that port. I tried out the same basic code that NumCore submitted (with a couple of alterations), my result was this - On port 21 - connection, but not a valid stream resource. On port 20 - server down So, I go to the admin page which is on port 20 and I pull up the xml page which is also on port 20. No problem. Then I try the same with port 21 .... no admin page, no xml, no 7.html. I understand it requires a different script to get the xml. I think it boils down to having to get the web host to open up the same exact port the DNAS is using. Pretty frustrating. The host is less than responsive ... Sorta like beating a dead horse. |
|
|
|
|
|
|
#19 | ||
|
Junior Member
|
Quote:
Quote:
// fpassthru($conn); |
||
|
|
|
|
|
#20 |
|
Major Dude
|
musiCode.. just change the DNAS port base to the port that is open on your web server, 21 in this case. The only prob about using port 21 is that usually you don't want to run something on a port assigned by default to another service, FTP in this case.
And numbcore, first make sure that you know what you're talking about, you got a warning on line 2 about the call to fsockopen() and you fixed it modifying the line 19 that has nothing to do with that warning... ![]() /btw, that code is 'inverted'... you're trying to get 7.html when there's no connection, check your first IF statement.. Words are very unnecessary, they can only do harm, so enjoy the silence - Depeche Mode Firemonger Project: Help spread Firefox Last edited by 101; 25th February 2005 at 16:23. |
|
|
|
|
|
#21 |
|
Junior Member
|
Haha! I keept asking myself why it said server offline when it really was online.
This is my new fuction... PHP Code:
|
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|