且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

配置WebSocket连接的身份验证标头

更新时间:2023-12-01 14:21:22

您应该通过Web进行身份验证,返回cookie,然后再次携带cookie再次连接到websocket服务器. WS服务器可以验证cookie

You should do the authentication through web, return a cookie and then connect to the websocket server again, carrying the cookie. The WS server can validate the cookie

如果没有基于cookie的身份验证,或者根本不可能(例如另一个域中的WS服务器),则必须创建自己的请求-响应消息进行登录.

If there is no cookie based authentication or it is just not possible (like the WS server in another domain), you will have to create your own request-response messages for login.