swooletw / laravel-swoole

High performance HTTP server based on Swoole. Speed up your Laravel or Lumen applications.
MIT License
4.04k stars 390 forks source link

Http request fired websocket disconnect event? #414

Closed pslxx closed 3 years ago

pslxx commented 4 years ago

Make sure you read Issues Guideline and answer these questions before submitting your issue. Thanks! (Any non-English issues will be closed immediately.)

  1. Please provide your PHP and Swoole version. (php -v and php --ri swoole) php:7.3.13 swoole:4.4.15

  2. Please provide your Laravel/Lumen version.

6.18

  1. Which release version of this package are you using?

2.6

  1. What did you do? If possible, provide a recipe for reproducing the error.

  2. What did you expect to see?

  3. What did you see instead?

pslxx commented 4 years ago
    protected function isServerWebsocket(int $fd): bool
    {
        return array_key_exists(
            'websocket_status',
            $this->container->make(Server::class)
                ->connection_info($fd)
        );
    }

这个方法在判断是否为websocket的fd的时候,如果全局开启了socket ,那么正常的HTTP请求也会被认为是soket链接,然后会触发disconnect事件 理论上此处加上判断 websocket_status 的值判断 image

因为这个问题,导致我在处理disconnect的时候出现障碍