我使用https://docs.microsoft.com/en-us/aspnet/signalr/overview/getting-started/tutorial-getting-started-with-signalr创建了点网核心SignalR客户端使用StartAsync连接需要1秒钟以上的时间。太久了我们如何减少启动时间?有需要调整的参数吗?
感谢您的回复和修正的链接。解决方案使用ASP.NetCore,并且将传输配置为仅使用WebSocket。服务器端(启动/配置)
app.UseEndpoints(endpoints =>
{
endpoints.MapHub<LiveHub>("/signalr/livehub", options =>
{
options.Transports = HttpTransportType.WebSockets;
});
});
控制台客户端应用程序是根据以下内容构建的:https://github.com/aspnet/AspNetCore.Docs/tree/master/aspnetcore/signalr/dotnet-client/sample/SignalRChatClient在客户下
connection = new HubConnectionBuilder()
.WithUrl("http://localhost:xxxx/signalr/livehub", options =>
{
options.SkipNegotiation = true;
options.Transports = HttpTransportType.WebSockets;
})
.Build();
代码执行时间是在客户端上计算出来的,>]
await connection.StartAsync();
对于多个测试用例,平均连接时间徘徊在900毫秒至1200毫秒之间。这是很长的时间。