【问题标题】:Signalr with angular and .net core error with code 1006Signalr 带有角度和 .net 核心错误,代码为 1006
【发布时间】:2020-05-31 08:12:10
【问题描述】:

在 IIS 上托管 Angular 应用程序时,我遇到信号器问题,它一直在控制台上显示以下错误:

[2020-05-31T08:09:00.838Z] Error: Connection disconnected with error 'Error: WebSocket closed with status code: 1006 ().'.

请记住,一旦我使用 nodeJs 托管了 Angular 应用程序,它就可以正常工作,但我需要在 IIS 上托管 Angular 应用程序。

我正在使用“@microsoft/signalr”和 aspcore 3.1

我的代码示例角度:

  constructor(private fb: FormBuilder, private router: Router) {
    //establish a new connection on the logging user group
    this.signalRConnection = new signalR.HubConnectionBuilder()
      .configureLogging(signalR.LogLevel.Information)
      .withUrl(this.hubUrl)
      .build();
    this.signalRConnection.start().then(() => {
      this.session.id = this.signalRConnection.connectionId;
      this.signalRConnection.send("RegisterOnlineUser", this.session, 'title', 'url');
      this.signalRConnection.send("GetOnlineUsers");
    });
  }

aspcore:


        public async void registerOnlineUser(SessionInfo session)
        {

            await Groups.AddToGroupAsync(Context.ConnectionId, session.group);

          await Clients.Group(Users).SendAsync("RegisterOnlineUser", session);


            }  

【问题讨论】:

  • 你在前端使用什么样的库作为信号器?你的后端是nodejs还是其他?
  • 你需要分享角度和核心部分代码来理解问题
  • 我使用前端的“@microsoft/signalr”作为角度,我的后端是 asp.net core 3.1
  • @aspnet/signalr 适用于核心 api 。在我的应用程序中,我将此库用于角度

标签: angular asp.net-core websocket asp.net-core-signalr


【解决方案1】:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-06-26
    • 2018-09-21
    • 2021-04-27
    • 2019-05-25
    • 2022-11-08
    • 1970-01-01
    • 2018-03-29
    • 2023-03-14
    相关资源
    最近更新 更多