User61956409 posted
Hi Albertk89,
Normally after connectivity between client and server is lost, the client tries to reconnect and the server waits for the client to reconnect. And SignalR connection would be ended once the attempts to reconnect are unsuccessful and the disconnect timeout
period ends. This mechanism could help client reconnect to hub server without starting a new connection.
If you want to improve user experience of your application while connection(s)/communications between client and server have some problems, you can try to put your key code snippet in try-catch block and show user notice message if any exceptions occur.
try
{
connection = new HubConnectionBuilder()
.WithUrl("{url_here}")
.Build();
await connection.StartAsync();
//other code logic here
}
catch (Exception ex)
{
//Console.WriteLine(ex.Message);
Console.WriteLine("Can not communicate with server now, please try later.");
}
Besides, if possible, please not explicitly Transports, let SignalR itself choose and use appropriate transports to make its connections.
With Regards,
Fei Han