TCP 连接不能在控制器推送
ykxiao opened this issue · 2 comments
ykxiao commented
-
Your software version (Screenshot of your startup)
Software Version PHP 8.0.26 Swoole 5.0.1 Laravel/Lumen 8.83.26 -
Detail description about this issue(error/log)
1: ✘ ykxiao@ip-192-168-43-20 ~ telnet 127.0.0.1 5291
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Welcome to cusService.
2:监听TCP后,在控制器推送消息时提示:"Swoole\WebSocket\Server::push(): the connected client of connection[2] is not a websocket client or closed" -
Some
reproducible
code blocks andsteps
use Swoole\WebSocket\Server; /** * @return JsonResponse */ public function tcpTest(): JsonResponse { /**@var \Swoole\Http\Server|Server $swoole */ $swoole = app('swoole'); $port = $swoole->ports[1]; foreach ($port->connections as $fd) { if ($swoole->isEstablished($fd)) { $swoole->push($fd, 'Send TCP message'); } } return $this->response->success(); }
hhxsv5 commented
发TCP消息用send(),isEstablished()和push()是针对WebSocket的。
// $swoole->send($fd, 'Send tcp message');
ykxiao commented
好的,了解