New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Console application using async/await stops receiving after sending #3895
Comments
I should point out, the reason I'm concerned about this even though it's just a spike is that the actual service I'm working on will be consumed from ASP.NET Web API services as well as WPF desktop applications. |
It's a very implicit deadlock. If you turn on tracing you will see that the messages are still being received by the client only your callback is not being invoked because the previous one has not finished yet:
On your side you could fix this by changing |
This thread is my async await experience in a nutshell. |
Fixing an issue where user's code would run a continuation of `HubProxy.Invoke` on a SignalR thread because we were using TaskCompletionSource with default settings. If the user's code blocked it would completely block the receive queue and the user will no longer get any notifications even though the client processes them and add to the queue. The fix is to dispatch the completion of `HubProxy.Invoke` to a different thread (note that we can't use `TaskCreationOptions.RunContinuationsAsynchronously` because some platforms we compile for do not support this).
Fixing an issue where user's code would run a continuation of `HubProxy.Invoke` on a SignalR thread because we were using TaskCompletionSource with default settings. If the user's code blocked it would completely block the receive queue and the user will no longer get any notifications even though the client processes them and add to the queue. The fix is to dispatch the completion of `HubProxy.Invoke` to a different thread (note that we can't use `TaskCreationOptions.RunContinuationsAsynchronously` because some platforms we compile for do not support this).
Fixing an issue where user's code would run a continuation of `HubProxy.Invoke` on a SignalR thread because we were using TaskCompletionSource with default settings. If the user's code blocked it would completely block the receive queue and the user will no longer get any notifications even though the client processes them and add to the queue. The fix is to dispatch the completion of `HubProxy.Invoke` to a different thread (note that we can't use `TaskCreationOptions.RunContinuationsAsynchronously` because some platforms we compile for do not support this).
Fixed in e55b89a |
I was working on a spike using a pair of console applications to send and receive messages, and hit a bit of odd behavior. In the subscriber application, once it had invoked a method on the Hub using an
await
, it stopped receiving new messages. Initially this meant it never received messages because it called aSubscribe
method right away, but digging into it I found that it would receive quite happily until it called a method.When the method is invoked with a
.Wait()
instead ofawait
everything is fine.I'm not sure if this is to do with the way threads are handled in console applications (as opposed to WPF applications which have a
SynchronizationContext
), or is down to a problem in the C# SignalR client.Expected behavior
Would expect to be able to
await hubProxy.Invoke("Foo");
and continue to receive messages.Actual behavior
Using
await hubProxy.Invoke("Foo");
breaks the connection somehow.Steps to reproduce
The text was updated successfully, but these errors were encountered: