So I have a C# client which invokes a method of the SignalR hub, where the hub will return a DateTime.
But the behaviour I am now experiencing, is that the client gets stuck at the HubProxy.Invoke which ends up on logging the following:
Possible deadlock detected. A callback registered with "HubProxy.On" or "Connection.Received" has been executing for at least 10 seconds.
This is the code of the client:
private async Task<long> GetCurrentServerTimeOffset()
{
DateTime requestDate = DateTime.Now;
DateTime serverDate = await hubProxy.Invoke<DateTime>("GetCurrentServerTime");
DateTime resultDate = DateTime.Now;
long offset = serverDate.Ticks - (requestDate.Ticks + resultDate.Ticks) / 2;
return offset;
}
This is the code of the Hub:
public DateTime GetCurrentServerTime()
{
return DateTime.Now;
}
I already tried replacing await hubProxy.Invoke<DateTime>("GetCurrentServerTime") with hubProxy.Invoke<DateTime>("GetCurrentServerTime").Result but it behaves the same...
Does anyone have an idea what I'm doing wrong, causing the deadling warning to be logged?
EDIT1: If I put a breakpoint in the return DateTime.Now; of the hub, the breakpoint is hit, and the hub has no problem sending its response to the client.
It's strange, but your code works well in my case. Maybe there something wrong with client / server configuration?
My simple server configuration:
Client configuration:
SignalR hub: