hhxsv5 / laravel-s

LaravelS is an out-of-the-box adapter between Laravel/Lumen and Swoole.
MIT License
3.82k stars 470 forks source link

The operation of websockets and dispatch_mode #465

Closed DevilSerj closed 7 months ago

DevilSerj commented 7 months ago
  1. Your software version (Screenshot of your startup)

+---------------------------+---------+ | Component | Version | +---------------------------+---------+ | PHP | 7.4.33 | | Swoole | 4.8.13 | | LaravelS | 3.7.36 | | Laravel Framework [local] | 8.25.0 | +---------------------------+---------+

  1. Detail description about this issue(error/log)

Why is the default value of dispatch_mode 3 and do you recommend using it? When the value of dispatch_mode = 3 then WARNING Server::start_check(): cannot set 'onClose' event when using dispatch_mode=1/3/7 That is, we will not be able to use onClose in websockets. Do I understand correctly? If I use websockets and I need onClose then I should use dispatch_mode = 2 right?

Thank you for your time!

  1. Some reproducible code blocks and steps

LARAVELS_DISPATCH_MODE=3

uptonyuan commented 7 months ago

这是来自QQ邮箱的假期自动回复邮件。你好,我最近正在休假中,无法亲自回复你的邮件。我将在假期结束后,尽快给你回复。

mnizfd commented 7 months ago

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

hhxsv5 commented 7 months ago

Why is the default value of dispatch_mode 3 and do you recommend using it? When the value of dispatch_mode = 3 then WARNING Server::start_check(): cannot set 'onClose' event when using dispatch_mode=1/3/7

For sync blocking HTTP Server, in order to use the Worker efficiently, it is recommended to set dispatch_mode=3. However, the onClose event cannot be supported under WebSocket Server. And Swoole will give you a WARNING message. If you do not need the onClose event, you can ignore it.

That is, we will not be able to use onClose in websockets. Do I understand correctly? If I use websockets and I need onClose then I should use dispatch_mode = 2 right?

If you want to use the onClose event, you can only set dispatch_mode=2/4/5