Timeout errors when trying to get info from server

101 views
Skip to first unread message

Mikeyxspikey

unread,
May 17, 2015, 1:57:04 PM5/17/15
to steam-c...@googlegroups.com
So, I've included the steam-condenser.php file at the top of my index.php file, and further down the page I have this PHP code;

    <?php 
      $ipAddress = "185.38.149.90";
      $portNumber = 27015;
      $server = new SourceServer($ipAddress, $portNumber);
      $server->getServerInfo(); 
      print_r($server->getPlayers());
    ?>

This is a Garry's Mod server which is password protected. I have tried a different server which is no password protected and I still get this error:

[17-May-2015 18:20:19 Europe/Berlin] PHP Notice:  Sending packet of type "A2S_INFO_Packet"... in /home/aovozpnq/public_html/dev/gw/lib/steam/sockets/SteamSocket.php on line 142
[17-May-2015 18:20:20 Europe/Berlin] PHP Fatal error:  Uncaught exception 'TimeoutException' with message 'The operation timed out.' in public_html/dev/gw/lib/steam/sockets/SteamSocket.php:108
Stack trace:
#0 public_html/dev/gw/lib/steam/sockets/SourceSocket.php(36): SteamSocket->receivePacket(1400)
#1 public_html/dev/gw/lib/steam/servers/GameServer.php(260): SourceSocket->getReply()
#2 public_html/dev/gw/lib/steam/servers/GameServer.php(302): GameServer->getReply()
#3 public_html/dev/gw/lib/steam/servers/GameServer.php(472): GameServer->handleResponseForRequest(1)
#4 public_html/dev/gw/lib/steam/servers/GameServer.php(235): GameServer->updateServerInfo()
#5 public_html/dev/gw/index.php(300): GameServer->getServerInfo()
#6 {main}
  thrown in public_html/dev/gw/lib/steam/sockets/SteamSocket.php on line 108

I've tried using both "getServerInfo();" and "initialize();" and still get this error.

All I want to do is get the number of players that are on a server. This info will then be used on the page.

Any help would be appreciated. Thanks.

Mikeyxspikey

unread,
May 19, 2015, 5:11:27 AM5/19/15
to steam-c...@googlegroups.com
Okay, so I found out it was to do with ports being blocked on my host.

However I not have another question. I have made a for loop which runs through an array of server IPs and will then echo some html with the server information for every server in the array. However, when a server is down, the script throws an uncaught exception timeout error. How could I check to see if the server is up first before displaying the information, in order to stop this error from breaking my for loop?

Thanks.

Sebastian Staudt

unread,
May 19, 2015, 5:14:07 AM5/19/15
to steam-c...@googlegroups.com
Hi.

You should probably catch the TimeoutException inside your for loop.
But please note that a timeout (by default) will occur after one second. Depending on the number and reliability of the servers you're querying this may have a considerable impact on the time the for loop is executing.

Best regards,
    Sebastian

--
You received this message because you are subscribed to the Google Groups "Steam Condenser" group.
To unsubscribe from this group and stop receiving emails from it, send an email to steam-condens...@googlegroups.com.
To post to this group, send email to steam-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/steam-condenser/3a0bc3a5-37c8-4166-835b-2151ad9a214f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages