SignalR Core JS 客户端未在 "Upgrade " 请求上传递授权标头
SignalR Core JS Client not passing Authorisation headrs on "Upgrade " Request
我必须使用 ASP .Net Core 实现推送通知服务。显而易见的选择是使用 SignalR Core。
我们的平台设置使用的是 Azure App 网关,并且配置为不允许未经身份验证的请求。
我们已经设置了与 SignalR 的 WebSockets 通信。
在幕后,SignalR Core 遵循以下步骤:
- POS ../negociate -> 确定 hub_token 并支持传输
- GET(发送升级 header 和 WebSockets 令牌)../Hub?id={hub_token} -?失败
在调查为什么步骤 2 没有将连接升级为 WebSocket 连接时,我注意到 GET 请求缺少授权 header。显然 AG 阻止了这个请求,甚至没有到达 API.
我试过用邮递员手动制作一个"handshake"。
以上步骤:
- 好的
- 包括授权 JWT header -> 结果 101,Fiddler 确认连接已打开。
我研究了文档,发现不支持授权 header。
有没有人尝试过任何解决方法? @aspnet/signalr 客户端的下一个版本是什么?
您是否指定了 accessTokenFactory
?
let connection = new signalR.HubConnectionBuilder()
.withUrl("/myhub", {
accessTokenFactory: () => {
// Get and return the access token.
// This function can return a JavaScript Promise if asynchronous
// logic is required to retrieve the access token.
}
})
.build();
更多信息here。
所以最终的解决方案是:
这在浏览器中是发送 JWT header 和 HTTP 101 UPGRADE
的限制
我必须使用 ASP .Net Core 实现推送通知服务。显而易见的选择是使用 SignalR Core。
我们的平台设置使用的是 Azure App 网关,并且配置为不允许未经身份验证的请求。
我们已经设置了与 SignalR 的 WebSockets 通信。
在幕后,SignalR Core 遵循以下步骤:
- POS ../negociate -> 确定 hub_token 并支持传输
- GET(发送升级 header 和 WebSockets 令牌)../Hub?id={hub_token} -?失败
在调查为什么步骤 2 没有将连接升级为 WebSocket 连接时,我注意到 GET 请求缺少授权 header。显然 AG 阻止了这个请求,甚至没有到达 API.
我试过用邮递员手动制作一个"handshake"。 以上步骤:
- 好的
- 包括授权 JWT header -> 结果 101,Fiddler 确认连接已打开。
我研究了文档,发现不支持授权 header。
有没有人尝试过任何解决方法? @aspnet/signalr 客户端的下一个版本是什么?
您是否指定了 accessTokenFactory
?
let connection = new signalR.HubConnectionBuilder()
.withUrl("/myhub", {
accessTokenFactory: () => {
// Get and return the access token.
// This function can return a JavaScript Promise if asynchronous
// logic is required to retrieve the access token.
}
})
.build();
更多信息here。
所以最终的解决方案是: 这在浏览器中是发送 JWT header 和 HTTP 101 UPGRADE
的限制