作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
两者有什么区别
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 和访问 token (如果有)进行响应。
客户请求
{
"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 中,这需要粘性 session 。为了避免使用粘性 session ,客户端需要跳过协商,但仅限于在没有 Azure 的情况下仅使用 websockets
。
来源:
关于angular - SignalR HubConnection 中的skipNegotiation 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69633704/
如何在 Blazor 服务器中启用 skipNegotiation 设置以避免粘性 session 在文档中 https://learn.microsoft.com/ru-ru/aspnet/core
我是一名优秀的程序员,十分优秀!