创建的连接如下:
ngOnInit(): void {
this._hubConnection = new HubConnectionBuilder()
.withUrl('http://localhost:44306/notify',
{ skipNegotiation: true, transport: HttpTransportType.WebSockets, accessTokenFactory: () => "" }).
build();
this._hubConnection
.start()
.then(() => console.log('Connection started!'))
.catch(err => console.log('Error while establishing connection :('));}
从不开始=>诺言没有解决
后端配置应该没有问题:Startup.cs
app.UseSignalR(routes =>
{
routes.MapHub<BroadcastMessage>("/notify");
});
和
public class BroadcastMessage : Hub<ITypedHubClient>
{
}
public interface ITypedHubClient
{
Task BroadcastMessage(string type, string payload);
}
signalrR库版本1.0.1