如何从Postman调用SignalR事件?

问题描述 投票:0回答:1

我想从 Postman 调用 SignalR 事件,我也经历过 this 问题,但这对我没有帮助。

它给出了以下错误,由于安全原因,在此示例中我已将 URL 提到为 myUrl。

下面是相同的 C# 等效代码。

private HubConnection hub connection;
private IHubProxy hubProxy;

hubConnection = new HubConnection(myUrl, useDefaultUrl: false);
hubConnection.TransportConnectTimeout = new TimeSpan(10000);
hubConnection.Credentials = CredentialCache.DefaultCredentials;
hubConnection.Closed += _hubConnection_Closed;
hubConnection.Error += _hubConnection_Error;

hubProxy = hubConnection.CreateHubProxy(myHubName);
hubProxy.On<CurrencyPair>("getItems", value =>
{
    DoSomething(value);
}

邮递员版本9.31.9

postman signalr signalr-hub signalr.client
1个回答
0
投票

如果您使用可通过 ASP.NET 应用程序访问的 SignalR 服务进行本地调试,则它应该可以使用以下 URL:

  • wss://localhost:sslport/myHub(使用 SSL)
  • ws://localhost:port/myHub(无 SSL)

其中 myHub 是您用于在

routes.MapHub
中映射服务器端集线器的名称。

© www.soinside.com 2019 - 2024. All rights reserved.