Fix unsolicited pong crash with keep alive enabled. Fixes #430

This commit is contained in:
Matt Bonneau 2016-05-26 00:39:14 -04:00
parent b0e72bb7da
commit 85ed94d5cb
2 changed files with 9 additions and 2 deletions

View File

@ -192,7 +192,7 @@ class WsServer implements HttpServerInterface {
}
public function enableKeepAlive(LoopInterface $loop, $interval = 30) {
$lastPing = null;
$lastPing = new Frame(uniqid(), true, Frame::OP_PING);
$pingedConnections = new \SplObjectStorage;
$splClearer = new \SplObjectStorage;

View File

@ -23,7 +23,14 @@ class BinaryEcho implements \Ratchet\WebSocket\MessageComponentInterface {
$loop = new $impl;
$sock = new React\Socket\Server($loop);
$app = new Ratchet\Http\HttpServer(new Ratchet\WebSocket\WsServer(new BinaryEcho));
$wsServer = new Ratchet\WebSocket\WsServer(new BinaryEcho);
// This is enabled to test https://github.com/ratchetphp/Ratchet/issues/430
// The time is left at 10 minutes so that it will not try to every ping anything
// This causes the Ratchet server to crash on test 2.7
$wsServer->enableKeepAlive($loop, 600);
$app = new Ratchet\Http\HttpServer($wsServer);
$sock->listen($port, '0.0.0.0');