hhxsv5 / laravel-s

LaravelS is an out-of-the-box adapter between Laravel/Lumen and Swoole.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The operation of websockets and dispatch_mode

DevilSerj opened this issue · comments

commented
  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

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