-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Labels
Description
AsyncUdpConnection 连接失败时调用 close 报错,如果拦截报错就可能导致回调引用不能释放。
Error: Call to a member function offReadable() on null in vendor\workerman\workerman\src\Connection\AsyncUdpConnection.php:134
兼容示例代码:
`
public function close(mixed $data = null, bool $raw = false): void
{
if ($data !== null) {
$this->send($data, $raw);
}
if($this->connected){
try {
$this->connected = false;
$this->eventLoop->offReadable($this->socket);
fclose($this->socket);
} catch (Throwable) {
}
}
// Try to emit onClose callback.
if ($this->onClose) {
try {
($this->onClose)($this);
} catch (Throwable $e) {
$this->error($e);
}
}
$this->onConnect = $this->onMessage = $this->onClose = $this->eventLoop = $this->errorHandler = null;
}
`