我为GOS启用了PDO定期Ping:WebSocketBundle,我仍然不时收到此错误:
09:41:28 ERROR [websocket] Connection error occurred Warning: Error
while sending QUERY packet. PID=30536 in /home/dev.symfony/libs/composer_vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php
10:00:23 ERROR [websocket] Connection error occurred
SQLSTATE[HY000]: General error: 2006 MySQL server has gone away in
/home/dev.symfony/libs/composer_vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php
line 107 ["connection_id" => 3365,"session_id" =>
"11667050395acf121709d30728596936"] []
另一点是,如果没有人使用dev服务器,在日志中没有错误,但如果我立即登录到这个错误。
github https://github.com/GeniusesOfSymfony/WebSocketBundle/issues/299也开设了问题 但没有答案,所以我也在这里问。谢谢。
答案 0 :(得分:0)
解决。问题是我在“onSubscribe”函数中的Topic中定义了周期性计时器,如:
public function onSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
{
...
$topicTimer = $connection->PeriodicTimer;
//Add periodic timer every 3 seconds update
$topicTimer->addPeriodicTimer('notifications', 3, function() use ($topic, $connection) {
$user = $this->clientManipulator->getClient($connection);
if($user) {
$counters = $this->globalVariables->getCounters($user);
$connection->event($topic->getId(),['msg' => $counters]);
}
});
...
}
但现在我改为“独立”定期,如此处所述[{3}} 并将其附加到websocket。现在数据库没有超时。
答案 1 :(得分:0)
值得注意的是,当您遵循Symfony文档并创建PdoSessionHandler http://symfony.com/doc/current/doctrine/pdo_session_storage.html时,您将在其中传递dsn而不是pdo服务,它将无法正常工作,因为会话处理程序将创建其他连接。要解决此问题,请像https://github.com/GeniusesOfSymfony/WebSocketBundle/blob/master/Resources/docs/SessionSetup.md
中所述创建一个pdo服务并将其传递给PdoSessionHandler。