SignalR HubConnection 中的 skipNegotiation 是什么意思?
What means skipNegotiation in SignalR HubConnection?
有什么区别
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 是什么意思:true。
谢谢!
在 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 中,这需要粘性会话。为避免使用粘性会话,客户端需要跳过协商但仅限于在没有 Azure 的情况下使用 websockets
。
来源:
有什么区别
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 是什么意思:true。
谢谢!
在 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 中,这需要粘性会话。为避免使用粘性会话,客户端需要跳过协商但仅限于在没有 Azure 的情况下使用 websockets
。
来源: