Skip to content

Client to Server Streaming with IAsyncEnumerable #9310

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

Merged
merged 14 commits into from
Apr 18, 2019

Conversation

mikaelm12
Copy link
Contributor

@mikaelm12 mikaelm12 commented Apr 12, 2019

Not ready for review. Just hacking something that works together. Time for some eyes on this. Got rid of a lot of similar code.
We're essentially adding checks for an IAsyncEnumerable type in the invocation params, associated themwith a stream id similarly to how we do with channels, then consume items from the stream and send them as StreamItem messages.

@Eilon Eilon added the area-signalr Includes: SignalR clients and servers label Apr 12, 2019
@mikaelm12 mikaelm12 marked this pull request as ready for review April 15, 2019 18:46
#if NETCOREAPP3_0
if (ReflectionHelper.IsIAsyncEnumerable(reader.GetType()))
{
_ = _sendIAsyncStreamItemsMethod
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Long term, we should store the Takss returned by _sendIAsyncStreamItemsMethod and _sendStreamItemsMethod and track them during connection teardown and log warnings if they don't complete within a timeout.

@mikaelm12 mikaelm12 changed the title [WIP] Client to Server Streaming with IAsyncEnumerable Client to Server Streaming with IAsyncEnumerable Apr 15, 2019
@mikaelm12
Copy link
Contributor Author

⬆️ 📅

Copy link
Member

@BrennanConroy BrennanConroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing needs to be fixed.

I wont make you do it in this PR, but we should consider refactoring this a little to avoid the captures in the local functions.

@mikaelm12
Copy link
Contributor Author

Hm there was a failure in one of the tests on the Mac Agent

Failed   Microsoft.AspNetCore.SignalR.Client.FunctionalTests.HubConnectionTests.CanCancelIAsyncEnumerableClientToServerUpload(protocolName: "messagepack", transportType: WebSockets, path: "/default")
  Error Message:
   System.Exception : 1 error(s) logged.
  Microsoft.AspNetCore.SignalR.HubConnectionHandler - ErrorProcessingRequest - TZXBaDo_sm2QkkjEa-5guQ - Error when processing requests.
  ===================
  System.Collections.Generic.KeyNotFoundException: No stream with id '1' could be found.

This means that the stream type wasn't detected on the client side and there the invocation didn't register the streaming id with the server.

@analogrelay analogrelay added this to the 3.0.0-preview5 milestone Apr 18, 2019
@mikaelm12
Copy link
Contributor Author

The error seemed to be an issue with how the MessagePackHubProtocol was (or was not actually) handling StreamBindingFailureMessages. It was just throwing instead of sending the binding failure messages

@mikaelm12
Copy link
Contributor Author

@aspnet-hello
Copy link

This comment was made automatically. If there is a problem contact ryanbrandenburg.

I've triaged the above build. I've created/commented on the following issue(s)
https://github.com/aspnet/AspNetCore-Internal/issues/2306

if (ReflectionHelper.IsIAsyncEnumerable(reader.GetType()))
{
_ = _sendIAsyncStreamItemsMethod
.MakeGenericMethod(reader.GetType().GetInterface("IAsyncEnumerable`1").GetGenericArguments())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikaelm12 is this right?

var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
try
{
async IAsyncEnumerable<string> clientStreamData()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dude, casing, 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the case settled on local functions? I could see the argument for using camelCase like you would for anything else with a local scope.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it settled it’s always pascal case because this is c# not java or JavaScript

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😅

@natemcmaster natemcmaster deleted the mikaelm12/IAsyncEnumerableClientArgs branch May 3, 2019 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-signalr Includes: SignalR clients and servers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants