PDA

View Full Version : Unable to find the socket transport "http"



1337
12-25-2007, 08:30 PM
When I'm coding my php script, i get this error message --

(Unable to find the socket transport "http" - did you forget to enable it when you configured PHP?)

what should i do?

linFox
12-25-2007, 10:53 PM
Do you mind posting the relavent bit of code (specifically the fsockopen() call)?

I don't use sockets much but from a couple minutes reading it seems like you've just specified the hostname parameter wrong.
There should no protocol in the hostname (unless using ssl or tls), so if you're using fsockopen("http://www.example.com"... and you're getting the error, change it to fsockopen("www.example.com"... and it should work.

1337
12-25-2007, 11:45 PM
well, im trying to connect stats to a shoutcast server, so the stats wont work unless the ip is " http://555.55.55.55 "

maybe hostmonsters php support isnt accepting http:// ?

linFox
12-26-2007, 03:20 AM
It's not that this particular config isn't accepting http://, it's how the actual PHP function works. There can be no protocol in the hostname var at all, unless it is ssl or tls.
A standard http socket request should work the same whether the protocol is there or not, so just try it without it there and see if it works.

1337
12-26-2007, 11:29 AM
it doesnt ;(
it's shoutcast hosting so the just the ip and port wont work, it requires the http:// here's the code for the stats config file


<?php
// Stats Information
// Grabs the xml from your radio server and displays it in a iframe that refreshes every 30 seconds.
//Configuration
$scdef = "radio"; // Default station name to display when server or stream is down
$scip = "http://205.209.144.16"; // ip or url of shoutcast server
$scport = "9190"; // port of shoutcast server
$scpass = "******"; // password to shoutcast server
//End configuration

?>


and here's part of the code to display the stats..


include('config_radio.php'); //you may edit this path to fit your server environment otherwise leave it alone
$scfp = fsockopen("$scip", $scport, &$errno, &$errstr, 10);
if(!$scfp) {
$scsuccs=1;
echo''.$scdef.' Is Currently Offline';
}
if($scsuccs!=1){
fputs($scfp,"GET /admin.cgi?pass=$scpass&mode=viewxml HTTP/1.0\r\nUser-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n");
while(!feof($scfp)) {
$page .= fgets($scfp, 1000);
}

linFox
12-26-2007, 07:33 PM
Well if the shoutcast server only accepts using http:// (which I still think is really strange), then you won't be able to use fsockopen().
You could try rewriting the connection script using other functions like file_get_contents or fopen/fread; shouldn't be overly hard.

1337
12-27-2007, 04:30 PM
:S im pretty rubbish at php

how would i rewrite it to make it work?

linFox
12-28-2007, 12:43 AM
<?php

// Config
$scdef = "radio";
$scip = "http://205.209.144.16"; // Include protocol; No trailing slash, path or port
$scport = "9190";
$scpass = "******";

$opts = Array(
'http' => Array(
'method' => "GET",
'header' => "User-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n"
)
);
$context = stream_context_create($opts);

$page = file_get_contents($scip.":".$scport."/admin.cgi?pass=".$scpass."&mode=viewxml", false, $context) OR
die("Error connecting to ".$scdef.": connection failure or incorrect settings!");

?>

That should do pretty much the same job.

r2b2
12-28-2007, 01:17 AM
If I recall correctly, don't you have to purchase a dedicated IP address to connect to any port outside of the standard HTTP range? (i.e. I don't know if you will be able to connect to 9190)

Could be wrong though...

linFox
12-28-2007, 06:15 AM
Yeah that's true, but from the look of the IP given there, I don't think he's trying to connect to any HM server.

You're not, are you?

shadmego
12-28-2007, 08:16 AM
It wouldn't matter, any direction, in or out, that is outside the standard range of ports for a website is blocked by the HM firewall. A dedicated IP address is needed to turn those ports on.

Again, verify this with support because they have the only official answer.

1337
12-30-2007, 10:55 PM
no, a cast control server
all my other hosts accepted http:// protocols

sjlplat
12-30-2007, 11:59 PM
Hostmonster only allows outgoing socket connections to port 80. If you want to use other ports, you have to purchase a dedicated IP.

sdasevne
12-31-2007, 04:47 AM
Posts: 1000
Congratulations on reaching 1,000!

r2b2
12-31-2007, 06:04 AM
Congratulations on reaching 1,000!

Yeah, you must talk too much... lol :D