I have a a SignalR client which seems to close straight after starting, the error message i get is:
"The server closed the connection with the following error: Connection closed with an error. InvalidOperationException: Sequence contains no elements"
The SignalR client is being used in a ASP.Net Core Web API project (within an API controller).
The Nuget package i am using is called Microsoft.AspNetCore.SignalR.Client (v 1.1.0)
My code looks like this:
try
{
//SEND MESSAGE TO HUB
var connection = new HubConnectionBuilder()
.WithUrl("https://sample.azurewebsites.net/ChatHub")
.Build();
connection.Closed += async (error) =>
{
//log error - this is getting called straight after StartAsync
};
await connection.StartAsync();
await connection.InvokeAsync("SendToATeam", "x", "y");
await connection.StopAsync();
}
catch (Exception ex)
{
//log error
}
OnConnectedAsync
? Can you show the code? – Zoltai