用swoole搭建的websocket服务器,经常会抛出 “ERROR zm_deactivate_swoole (ERROR 503): Fatal error: Uncaught ErrorException: swoole_http_client::push(): websocket handshake failed, cannot push data.” 异常。但是大部分时间还是可以连接上的。
我的php版本是7.0.29,系统是CentOS 7.4.1708,swoole版本是 1.10.5
我是在同一个服务器上,用swoole搭建的tcp服务中,通过:
$cli = new \swoole_http_client('localhost', 9510);
$cli->setHeaders([
'UserAgent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36'
]);
$cli->on('message', function ($_cli, $frame) {
});
$cli->upgrade('/', function ($cli) use ($cabinetid, $param, $state, $head) {
try {
$ret = $cli->push($head . $cabinetid . $param . $state);
if (!$ret) {
$cli->push($head . $cabinetid . $param . $state);
}
} catch (Exception $exc) {
$cli->push($head . $cabinetid . $param . $state);
}
});
以上代码向 同一个服务器中的websocket服务发送消息的时候抛出的异常
请问是什么原因?我该如何查找原因呢?