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

请问一个关于websocket路由的问题

ttAllen1 opened this issue · comments

commented

作者在

 App\Services\WebSocketService 的示例代码中
onOpen() 中有这样一行注释:Then the /ws route in Laravel needs to add the middleware like Authenticate

我有几个疑问,希望大佬们帮忙理清下思路:

  1. 这里的路由/ws 按照作者的意思是走了laravel的路由,并且经过了相关中间件的处理,拿到当前用户相关的一些数据。这给我的感觉是一次http请求,服务器响应后应该会断开连接。但是,反向代理nginx中也匹配了一个/ws的location。我就不太理解这两处的/ws的具体应用。
  2. 客户端在申请建立websocket连接之前,确实会先发送一次http请求,但是这个http请求应该不会走到laravel的路由中。反向代理服务器直接响应101

再次感谢大佬们,能帮忙解除心中的疑惑谢谢!!!万分感谢