问题描述
我有一个客户端(angular)应用程序服务和一个 api(net core 3.1)应用程序服务,我试图通过信号器相互通信。它在带有 websocket 的本地主机上运行良好,但在 azure 应用程序服务上它只适用于长轮询传输模式,即使我在配置中启用了 websocket。协商返回 200 与 connectionId 和所有三个 availableTransports。但是wss请求返回404如下图。
SELECT pagetitle as Action,Title as MainTitle,FROM QoQueries
ORDER BY pageTitle asc
我已经尝试查看大量资源和文档来解决这个问题,因此感谢您提供任何帮助。这是我的配置:
在startup.cs中
WebSocket connection to 'wss://xxxx.azurewebsites.net/notifications?id=ZI0-a_p5G6YziWhCxxc7Kg&access_token=eyJhbGc.. Failed: Error during WebSocket handshake: Unexpected response code: 404
Utils.js:218 [2021-03-25T18:21:13.045Z] Error: Failed to start the transport 'WebSockets': Error: There was an error with the transport.
在客户端
options.AddPolicy(MyAllowSpecificOrigins,builder =>
{
builder.WithOrigins("https://xxxxx-dev.azurewebsites.net").AllowAnyMethod().AllowAnyHeader().AllowCredentials();
builder.WithOrigins("http://localhost:4200").AllowAnyMethod().AllowAnyHeader().AllowCredentials();
});
....
services.AddControllers();
services.AddSignalR();
....
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapHub<NotificationHub>("/notifications");
});
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)