手冊中寫的是
返回值
返回 $worker_connnections 中的一個連接對象。如果沒有可返回的$worker_connnections,則返回false。
然后我這樣寫return false;
最終報錯了竟然
PHP Fatal error: Call to a member function send() on boolean in /share/gatewayworker/vendor/workerman/gateway-worker/src/Gateway.php on line 414
Fatal error: Call to a member function send() on boolean in /share/gatewayworker/vendor/workerman/gateway-worker/src/Gateway.php on line 414
Worker[21969] process terminated with ERROR: E_ERROR "Call to a member function send() on boolean in /share/gatewayworker/vendor/workerman/gateway-worker/src/Gateway.php on line 414"
看了源碼好像是沒有對返回的worker_connection錯判斷
$worker_connection = call_user_func($this->router, $this->_workerConnections, $connection, $cmd, $body);
if (false === $worker_connection->send($gateway_data)) {
$msg = "SendBufferToWorker fail. May be the send buffer are overflow. See http://doc2.workerman.net/send-buffer-overflow.html";
static::log($msg);
return false;
}