Following the IAsyncEnumerable example code from here:
https://docs.microsoft.com/en-us/aspnet/core/signalr/streaming?view=aspnetcore-3.0
I can't get the .Net client to bind...
System.IO.InvalidDataException: Invocation provides 2 argument(s) but target expects 3.
at Microsoft.AspNetCore.SignalR.Protocol.NewtonsoftJsonHubProtocol.BindArguments(JsonTextReader reader, IReadOnlyList`1 paramTypes)
at Microsoft.AspNetCore.SignalR.Protocol.NewtonsoftJsonHubProtocol.ParseMessage(Utf8BufferTextReader textReader, IInvocationBinder binder)
Exception thrown: 'Microsoft.AspNetCore.SignalR.HubException' in System.Private.CoreLib.dll
An unhandled exception of type 'Microsoft.AspNetCore.SignalR.HubException' occurred in System.Private.CoreLib.dll
Failed to invoke 'Counter' due to an error on the server.
If I add a second cancellationToken...
var channel = await connection.StreamAsChannelAsync<int>("Counter", 100, 1000, tokenSource.Token, tokenSource.Token);
I get...
The client attempted to invoke the non-streaming 'Counter' method with a streaming invocation.
Client
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.0.0-preview3-19153-02" />
Server
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RootNamespace>IAsyncEnumerable_demo</RootNamespace>
</PropertyGroup>
</Project>
Check the .NET target framework(s) being used, and include the version number(s).
If using the .NET Core SDK, include dotnet --info output. If using .NET Framework without the .NET Core SDK, include info from Visual Studio's Help > About Microsoft Visual Studio dialog.
dotnet --info output or About VS info
D:\dev> dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.0.100-preview3-010431
Commit: d72abce213
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17134
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.0.100-preview3-010431\
Host (useful for support):
Version: 3.0.0-preview3-27503-5
Commit: 3844df9537
.NET Core SDKs installed:
2.1.4 [C:\Program Files\dotnet\sdk]
2.1.101 [C:\Program Files\dotnet\sdk]
2.1.104 [C:\Program Files\dotnet\sdk]
2.1.201 [C:\Program Files\dotnet\sdk]
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.504 [C:\Program Files\dotnet\sdk]
2.1.505 [C:\Program Files\dotnet\sdk]
2.1.601 [C:\Program Files\dotnet\sdk]
3.0.100-preview3-010431 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-preview3-19153-02 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview3-27503-5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0-preview3-27504-2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
I believe this feature went in right after preview3 branching. So it will be available in preview4 or nightly bits.
Looks like we were a little over-eager to write docs for it, sorry.
Thanks for confirming!
@BrennanConroy: I am getting the same exception using the latest version (3.1.1) of Microsoft.AspNetCore.SignalR.Client, i.e. I can't seem to bind to a hub method that accepts a CancellationToken.
Is this the expected current behavior? If I can't use a CancellationToken in the hub, how do I then determine when a (.NET) client disconnects from the stream?
Why hasn't the docs been updated and why isn't the .NET client code included in the downloadable code sample?
I am getting the same exception
What exception? There were multiple listed.
The .NET client code can be seen in the docs at https://docs.microsoft.com/aspnet/core/signalr/streaming?view=aspnetcore-3.1#net-client
I can confirm that the sample code works as expected.
The reason why I got an InvalidDataException with the message "Invocation provides 2 argument(s) but target expects 3" in the client was because I unintentionally returned a Channel<T> from the streaming method in the hub instead of a ChannelReader<T>. :flushed:
This is an old doc issue from before the streaming feature was release. I think there are no actionable items left.
Most helpful comment
I believe this feature went in right after preview3 branching. So it will be available in preview4 or nightly bits.
Looks like we were a little over-eager to write docs for it, sorry.