ERROR: Connection timed out (110) >> shoutcast

Asked

Viewed 298 times

1

Good night. I’m having a problem with a radio shoutcast connection code. In 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]);
    }
?>

Has or has ever seen a solution to this connection?

1 answer

0

Sometimes the remote server is slow to respond and there is usually a time limit (~30s, in general) for it to be returned until the network socket closes and returns an outdated connection time error (timeout). I’m not quite 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 mistake, 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 hosting do not release ports for connection with shoutcast, but I’m not sure if it is your case, because another error is that it would return, instead of expired connection. But in any case...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.