我尝试为 ASP.NET Core 实现 SignalR,如下所述:https ://aspnetboilerplate.com/Pages/Documents/SignalR-AspNetCore-Integration但我总是得到一个错误。浏览器控制台输出:DEBUG: Starting connection using WebSockets transportInformation: Normalizing '/signalr-myChatHub' to 'http://localhost:62114/signalr-myChatHub'SCRIPT12008: WebSocket Error: Incorrect HTTP response. Status code 400, Bad Request我正在使用所有软件包 3.6.2 和 Abp.AspNetCore.SignalR 3.6.2-preview6 的最新版本。Web.Host/Startup.cs:#elif FEATURE_SIGNALR_ASPNETCORE app.UseSignalR(routes => { routes.MapHub<AbpCommonHub>("/signalr"); routes.MapHub<MyChatHub>("/signalr-myChatHub"); // Prefix with '/signalr' });#endif复制粘贴MyChatHub.cs:public class MyChatHub : Hub, ITransientDependency{ public IAbpSession AbpSession { get; set; } public ILogger Logger { get; set; } public MyChatHub() { AbpSession = NullAbpSession.Instance; Logger = NullLogger.Instance; } public async Task SendMessage(string message) { await Clients.All.SendAsync("getMessage", string.Format("User {0}: {1}", AbpSession.UserId, message)); } public override async Task OnConnectedAsync() { await base.OnConnectedAsync(); Logger.Debug("A client connected to MyChatHub: " + Context.ConnectionId); } public override async Task OnDisconnectedAsync(Exception exception) { await base.OnDisconnectedAsync(exception); Logger.Debug("A client disconnected from MyChatHub: " + Context.ConnectionId); }}或多或少复制粘贴的视图:@using EMetall.Web.Startup@section scripts{ <environment names="Development"> <script src="~/lib/signalr-client/signalr.min.js"></script> <script src="~/lib/abp-web-resources/Abp/Framework/scripts/libs/abp.signalr-client.js"></script> </environment>
2 回答
Cats萌萌
TA贡献1805条经验 获得超9个赞
您需要使用以下兼容版本:
Abp.AspNetCore.SignalR(目前为 3.6.2-preview6),
来自@aspnet/signalr 的signalr.min.js(当前为 1.0.0-rc1-update1),以及
abp.signalr-client.js(目前为 3.6.2)将在abp-web-resources 上发布。
- 2 回答
- 0 关注
- 216 浏览
添加回答
举报
0/150
提交
取消