In the following part of a class, StartAsync never returns.
Any ideas why? The server appears to be working fine, and works with Javascript clients.
SignalR client version is v1.0.0-rc1-final
public HubUtil(string baseUrl) //string clientId
{
connection = new HubConnectionBuilder()
.AddJsonProtocol()
.WithUrl(baseUrl) // baseUrl is "https://hostname/hubname"
.Build();
connection.Closed += Connection_Closed;
StartIfNeededAsync();
}
private Task Connection_Closed(Exception arg)
{
return StartIfNeededAsync();
}
public async Task StartIfNeededAsync()
{
if (_connectionState == ConnectionState.Connected)
{
return;
}
try
{
await connection.StartAsync(); // Never connects
_connectionState = ConnectionState.Connected;
}
catch (Exception ex)
{
_connectionState = ConnectionState.Faulted;
throw;
}
}
From a basic console app this is how hubutil is called:
static void Main(string[] args)
{
var hub = new HubUtil("https://host/hubname");
hub.Invoke("checkin", "id", "");
}
StartIfNeededAsync
is an async method without await, that's the first sign something is terribly wrong – MelanismHubUtil
? What project type is this running on? – MelanismStartAsync
is the symptom and not necessarily the cause. – NomanomadTask.Run(() => StartIfNeededAsync());
in constructor instead ofStartIfNeededAsync();
– Priory