ERROR: Connection timed out (110) shoutCast

1

Good evening. I'm having a problem with a connection code from a shoutCast radio. In the localhost: 127.0.0.1/tributus/server/on.php it returns the music that is passing normal, already hosted it returns as a connection error:

Connection timed out (110)

<?php
    $ip = "170.75.145.250"; 
    $port = "17652";
    $conexao = @fsockopen($ip,$port,$errno,$errstr,1); 

    if (!$conexao) {
        echo "$errstr ($errno)<br />\n";
    } else {
        fputs($conexao, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");

        while (!feof($conexao)) {
            $dados = fgets($conexao);
        }

        $dados = str_replace('</body></html>', "", $dados);
        $resultado = explode(',', $dados);
        echo($resultado[6]);
    }
?>

Does anyone have or have ever seen a solution to this connection?

    
asked by anonymous 18.08.2015 / 01:26

1 answer

0

Sometimes the remote server is slow to respond and there is usually a timeout (~ 30s, in general) so that it is returned until the network socket closes close and returns a timeout error. I'm not very sure about, testing here your shoutcast server responds quickly. However, in your code, you set the 5th parameter of fsockopen () to 1 second timeout. Maybe there's the error, you should have something like this:

<?php 

define('TIMEOUT', 30);

$fp = fsockopen("www.example.com", 80, $errno, $errstr, TIMEOUT);

Also, I've heard cases that some hosts do not release ports for connection to shoutcast, but I'm not sure if that's the case, because another error is that it would return, rather than an expired connection. But in any case ...

    
18.08.2015 / 01:42