-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I am developing an application that will accept a stream from a Raspberry Pi client using a golang implementation of SignalR (github.com/philippseith/signalr) and consume it in an ASP.NET Core web app. Per the documentation here,
A hub method automatically becomes a client-to-server streaming hub method when it accepts one or more objects of type ChannelReader or IAsyncEnumerable.
Unless I am misunderstanding this statement, a hub method with the following signature should be recognized as a streaming method:
public async Task ReceiveStream(IAsyncEnumerable<string> data)
However, when I attempt to push a stream from the golang client, the connection is unsuccessful, and SignalR provides the following message back to the client:
Error:\"The client attempted to invoke the non-streaming 'ReceiveStream' method with a streaming invocation.\"
If I instead set the hub method signature to:
public async Task<IAsyncEnumerable> ReceiveStream(IAsyncEnumerable<string> data)
and provide an unused return IAsyncEnumerable object, streaming from the client works exactly as expected.
Searching the code base for the specific error message returned to the client turns up the DefaultHubDIspatcher.ValidateInvocationMode method, which appears to be failing the invocation on this test:
if (!hubMethodDescriptor.IsStreamResponse && isStreamResponse)
We can see here from the original (non-working) method signature that this hub method does not have a stream response, hence the failure at this check. There appears to be no check that the hub method descriptor has Stream Parameters, which should also indicate the the method is a streaming method, per the documentation.
Expected Behavior
A hub method with a non-streaming return type but with streaming parameters should be recognized as a streaming method by the hub dispatcher in the DefaultHubDispatcher.ValidateInvocationMode checks.
Steps To Reproduce
Minimal reproducable example here: https://github.com/blue-shoes/SignalR-Stream-Issue
Exceptions (if any)
No response
.NET Version
No response
Anything else?
Run in Visual Studio Professional 2022 LTSC 17.0.0.
