【发布时间】:2022-01-07 04:59:11
【问题描述】:
在使用角度连接 signalR 时出现错误
未捕获(承诺中):错误:如果连接未处于“已连接”状态,则无法发送数据。”
我的代码是
dashboard.service.ts
private hubConnection: signalR.HubConnection
initWebSocket() {
this.hubConnection = new signalR.HubConnectionBuilder()
//.configureLogging(signalR.LogLevel.Debug)
.withUrl('http://localhost:5000/Notification',{
skipNegotiation: true,
transport: signalR.HttpTransportType.WebSockets
})
.build();
this.hubConnection
.start()
.then(() => console.log('Connection started'))
//.then(() => console.log(this.hubConnection.connectionId)
.catch(err => console.log('Error while starting connection: ' + err))
const EmailId = "abc@mail.com";
this.hubConnection.invoke("Registerd", EmailId);
console.log("Registered", EmailId);
谁能帮我克服这个错误
【问题讨论】:
标签: angular signalr signalr-hub asp.net-core-signalr