连接到SignalR核心时,我们需要输入什么URL。
当我们尝试将网址设置为https://localhost:44308
时,表示找不到。是,Web服务器正在运行。是否需要后缀?
HubConnection connection;
connection = new HubConnectionBuilder()
.WithUrl(**Url**)
.Build();
await connection.StartAsync();
bool isClosed = false;
connection.Closed += async (error) =>
{
isClosed = true;
await Task.Delay(new Random().Next(0, 5) * 1000);
await connection.StartAsync();
};
if (isClosed == false)
{
connection.InvokeAsync("NewMessage", "from server", $"{DateTime.Now.ToShortDateString()}").Wait();
}