0

I'm hoping there is a quirk about apache/php that I'm missing.

The Code:

<?php
    $servers = array(
        array("70.89.xxx.226",25565,''),
        array("50.22.xxx.147",25591,''),
    );

    foreach($servers as $key=>$server){
        $fp = @fsockopen($server[0],$server[1],$errno,$errstr,.5);
        if(!$fp) {
            $servers[$key][2] = "DOWN";
        } else {
            $servers[$key][2] = "UP";
            @fclose($fp);
        }
        unset($fp);
    }


    echo"
    <table>
        <thead>
            <td>Minecraft Server Status</td>
        </thead>";

    foreach ($servers as $key=>$server){
        $keyplus = $key + 1;
        echo"
        <tr>
            <td>Server $keyplus: $server[0]:$server[1]</td>
            <td>$server[2]</td>
        </tr>";
    }

    echo "
    </table>";
    ?>

What it does: check connectivity to a variety of minecraft servers with the fsockopen function.

The problem: This code does exactly what it's supposed to do on both my local and my remote web servers. However, on my remote server, the status always displays as DOWN even when I know they are UP, they also display as UP on my local server. I can't figure out WHY my host wouldn't be able to reach these servers, so I hope its a server quirk i don't know about.

How you can help: Maybe theres another way to effectively ping an IP in php that I could use? or maybe you know of a server setting that is effecting my connectivity.

thank for reading and your time ~TylerTofWA

4

2 回答 2

0

解决。

我联系了我的托管公司并得到以下信息:

泰勒!

谢谢您联络我们。

您的脚本运行了大约 10 秒,但它确实运行了:

[/root]# time php -q -f /tmp/nanno

   <table>
           <thead>
                   <td>Minecraft Server Status</td>
           </thead>
           <tr>
                   <td>Server 1: 70.89.xxx.226:25565</td>
                   <td>DOWN</td>
           </tr>
           <tr>
                   <td>Server 2: 50.22.xxx.147:25591</td>
                   <td>DOWN</td>
           </tr>
   </table> real    0m10.071s user    0m0.047s sys     0m0.019s

坏消息是,您的服务器已关闭。但是,您的脚本的这一部分很好;) ...我确实得到:Minecraft Server Status Server 1: 70.89.xxx.226:25565 DOWN Server 2: 50.22.36.xxx:25591 DOWN on

(所以看起来您的浏览器或 http 连接正在超时)。除非您知道调整脚本以降低超时变量、浏览器网络超时设置的方法,或者如果您要同时运行两个 fsocks,您将获得运行时间?

如果您有任何其他问题或疑虑,请告诉我们。

问候,

------ Robert C. 服务器分析师 II SurpassHosting.com, LLC http://www.surpasshosting.com http://www.surmunity.com


我:感谢您的及时回复!

好吧,它花了十秒钟,因为有两次连接尝试超时 5 秒。

问题是它们不应该超时,我现在在服务器中,我的本地服务器可以连接 fsockopen 没问题,并将它们显示为 UP。

我不明白为什么我的脚本不能从我的网络服务器“看到”我的游戏服务器。

谢谢你的时间,泰勒


他们:你好泰勒,

问题已解决,您现在可以查看状态。

谢谢

此致, Praveen M 高级 Unix 管理员 SurpassHosting.com, LLC http://www.surpasshosting.com http://www.surmunity.com

我不知道他们是否会告诉我问题出在哪里,我很好奇。虽然在第一次回应时哈哈。

于 2011-03-25T11:24:06.957 回答
0

删除@onfsockopen以停止抑制错误以查看远程服务器上是否出现错误。还要确保error_reporting设置为使用显示所有错误error_reporting(A_ALL)

于 2011-03-25T03:55:07.567 回答