无法与signalR建立连接

时间:2019-01-01 16:27:19

标签: angular asp.net-core signalr

创建的连接如下:

    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

0 个答案:

没有答案