Closed CodingDK closed 8 years ago
Looks like it's leaking file descriptors. Restarting should fix this temporarily.
I'll have a look at the code, to see where this is originating from.
I could not find a possible reason for this. Sockets and their file descriptors should be automatically closed once they are destructed. In a cronjob this should happen right after execution.
Can you install the sockets
PHP extension on your server? Would be interesting to see if it happens with that, too.
Can you provide some of your code?
Does this occur more often when you execute the cronjob in shorter intervals?
My host is a cheap one (unoeuro), unfortunately I do not have the option of installing PHP extensens.
My code (this is the simple prototype, but if you want the 500 linies cronjob code, just say it):
<?php
require_once '../lib/steam-condenser.php';
try {
$server = new SourceServer('ip', 'port');
echo $server->getPing();
}
catch (Exception $e) {
echo $e;
}
?>
My cronjobs task was pinging our css server, every 3-4 minutes, and if there was no response 4 times in a row, it should log into our css hosts controlpanel and restart CSS server. And because of the TimeoutException
, the job also will restart the css server, so right now i dont want to use it anyway.
I have just written to my host in order to get them to restart the web server.
It seems that this warning is a problem of stream_select()
. Can you try to modify the file Socket.php
at line 155 to:
$select = @stream_select($read, $write, $except, $sec, $usec);
This seems to be a warning and can be simple skipped by adding the @
. Nevertheless it hints at dangling open sockets.
The warning is gone now, but it still make the TimeoutException. I have tryed several servers.
Can you provide one of the IPs you're trying to ping. I'll try to reproduce this.
46.174.49.21:27260
The timeouts are not related to the warning. I could reproduce them multiple times without getting the warning once. You should probably adapt your script to handle sporadic timeouts more gracefully.
The problem is that it makes timeoutException all the time right now, even with the script I posted above
I'm sorry. It seems I'm unable to reproduce this issue. How long does it take from a working script to the warnings above and the permanent timeouts afterwards? Minutes, hours, days?
Had a test script (and without the sockets
extension) running for a few hours without any problem.
I fear this is some host specific problem that cannot be fixed codewise.
If I make a php script (cronjob) for pinging a CS Source server with:
echo $server->getPing()
.It make a timeoutexception. The most strange is that the script has worked fine for several days, but now it has started with this error
Output is:
Notice: Sending packet of type "A2S_INFO_Packet"... in /var/www/site.com/lib/steam/sockets/SteamSocket.php on line 142
Warning: stream_select() [function.stream-select]: You MUST recompile PHP with a larger value of FD_SETSIZE. It is set to 1024, but you have descriptors numbered at least as high as 2111. --enable-fd-setsize=3072 is recommended, but you may want to set it to equal the maximum number of open files supported by your system, in order to avoid seeing this error again at a later date. in /var/www/site.com/lib/Socket.php on line 155
exception 'TimeoutException' with message 'The operation timed out.' in /var/www/site.com/lib/steam/sockets/SteamSocket.php:108 Stack trace:
0 /var/www/site.com/lib/steam/sockets/SourceSocket.php(36): SteamSocket->receivePacket(1400)
1 /var/www/site.com/lib/steam/servers/GameServer.php(260): SourceSocket->getReply()
2 /var/www/site.com/lib/steam/servers/GameServer.php(397): GameServer->getReply()
3 /var/www/site.com/lib/steam/servers/GameServer.php(167): GameServer->updatePing()
4 /var/www/site.com/cssPing.php(7): GameServer->getPing()
5 {main}