angular - SignalR HubConnection中的skipNegotiation是什么意思?
问题描述
之间有什么区别
this.hubConnection = new signalR.HubConnectionBuilder()
.withUrl(environment.API_URL + "invoicinghub", {
skipNegotiation: true,
transport: signalR.HttpTransportType.WebSockets
})
.withAutomaticReconnect([0, 2000, 10000, 30000, null])
.build();
和
this.hubConnection = new signalR.HubConnectionBuilder()
.withUrl(environment.API_URL + "invoicinghub", {
transport: signalR.HttpTransportType.WebSockets
})
.withAutomaticReconnect([0, 2000, 10000, 30000, null])
.build();
这是什么skipNegotiation:是的。
谢谢!
解决方案
在 SignalR 中,客户端首先向服务器发送协商请求,服务器会使用重定向 URL 和访问令牌(如果有)进行响应。
客户要求
{
"connectionId":"807809a5-31bf-470d-9e23-afaee35d8a0d",
"availableTransports":[
{
"transport": "WebSockets",
"transferFormats": [ "Text", "Binary" ]
},
{
"transport": "ServerSentEvents",
"transferFormats": [ "Text" ]
},
{
"transport": "LongPolling",
"transferFormats": [ "Text", "Binary" ]
}
]
}
服务器响应
{
"url":"https://test.service.signalr.net/client/?hub=chat&...",
"accessToken":"<a typical JWT token>"
}
只有在收到服务器的响应后,客户端才会建立连接。
在 SignalR Core 中,但不是在 SignalR ASP 中,这需要粘性会话。为了避免使用粘性会话,客户端需要跳过协商,但仅限于在websockets
没有 Azure 的情况下使用。
资料来源:
推荐阅读
- sql - 连接后如何转换为日期数据类型?
- join - Flink:是否支持多种执行环境?
- google-apps-script - 使用谷歌脚本将谷歌电子表格的范围变成图像
- tableau-api - 计算字段/LOD
- javascript - 如何解决每个字段问题的 php 复选框循环?
- python - 在给定位置 (X,Y) 的情况下,沿第三轴 (Z) 更新 rank3 张量流张量中的切片
- symfony - 如何在 Apache 中设置 Symfony3 环境
- sql - 将 XML 变量从存储过程传递到 SQL 服务器中的另一个存储过程
- vba - 如何将自动填充的表单记录(从另一条记录创建)添加到访问表中?
- cordova - Framework7 v5 包含自定义 js 文件的最佳方式