为了账号安全,请及时绑定邮箱和手机立即绑定

WebSocket 错误:HTTP 响应不正确。状态码 400,错误请求

WebSocket 错误:HTTP 响应不正确。状态码 400,错误请求

C#
千巷猫影 2021-07-01 14:24:18
我尝试为 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个赞

您需要使用以下兼容版本:


查看完整回答
反对 回复 2021-07-10
  • 2 回答
  • 0 关注
  • 216 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信