Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

websocket 握手请求中可否支持自定义 header ? #65

Open
cupen opened this issue Feb 20, 2019 · 1 comment
Open

websocket 握手请求中可否支持自定义 header ? #65

cupen opened this issue Feb 20, 2019 · 1 comment

Comments

@cupen
Copy link

cupen commented Feb 20, 2019

如题,自定义 header 主要是同步一些需要在握手时检查的状态,包括且不限于 session 。
目前的 api ,看起来似乎能用 url + querystring

ws = new Laya.Socket();
ws.connectByUrl(url);

未来的版本可否考虑加个 headers 参数?

headers = {
    "foo": "bar"
}
ws = new Laya.Socket();
ws.connectByUrl(url, headers);
@cupen cupen closed this as completed Apr 24, 2019
@cupen cupen reopened this Apr 24, 2019
@cupen cupen closed this as completed Apr 24, 2019
@cupen
Copy link
Author

cupen commented May 29, 2019

Hi 在下又遇到这个问题了,斗胆重提一下。
最近用 nginx 配置负载均衡,加了定向转发,为了保证同一个玩家的请求会路由到同一个服务端。

hash $http_header_name consistent;

普通 http 请求没问题,奈何 websocket 无法发送 header …… 无法保障客户端发出的 websocket 握手请求跟其他请求一样到达同一个服务端。而在下又特别希望能基于 header 做转发,这可有点纠结了。
只要 laya 的 websocket api 支持 headers ,一切问题都烟消云散。

@cupen cupen reopened this May 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant