Skip to content
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

GRPC.Core is being phased out #584

Closed
lucasmontec opened this issue Dec 19, 2022 · 7 comments
Closed

GRPC.Core is being phased out #584

lucasmontec opened this issue Dec 19, 2022 · 7 comments

Comments

@lucasmontec
Copy link

As per https://grpc.io/blog/grpc-csharp-future/ the GRPC Core implementation used by this package is being phased out. The new builds don't include the unity package anymore, nor they include an implementation usable. How is this library going to handle this change?

@binhnguyen86
Copy link

Up, same question here @mayuki
I heard we have a plan onboard .net grpc?

@mayuki
Copy link
Member

mayuki commented Dec 19, 2022

At this time, we use the build that was distributed by gRPC nightly build. It can be found at the following URL:
https://packages.grpc.io/archive/2022/04/67538122780f8a081c774b66884289335c290cbe-f15a2c1c-582b-4c51-acf2-ab6d711d2c59/index.xml

We are considering porting SocketHttpHandler for the future. (This is currently in the research/PoC phase.)
#501 (comment)

Another option seems to be a gRPC client with BestHTTP/2 as a backend. Although it requires a paid asset, it is worthy to consider using this one.
https://github.com/doctorseus/grpc-dotnet-unity

In any case, gRPC remains the major choice today, while it will take time for Unity's backend to migrate to .NET CLR.
We will continue to look for and invest in the way of gRPC in Unity.

@lucasmontec
Copy link
Author

lucasmontec commented Dec 19, 2022

BestHTTP/2 seems to be an actually excellent implementation of http/2. This could be a temporary fix indeed. Thanks for the in-depth explanation. Do you think it is worth keeping this issue open while you guys figure it out? Or should I close it?

@59-36
Copy link

59-36 commented Dec 22, 2022

Is the BestHTTP/2 Method supported on the latest MagicOnion release? I tried implementing it by adding "USE_GRPC_NET_CLIENT" and "USE_GRPC_NET_CLIENT_ONLY" into the Scripting Define Symbols but I keep getting the following error when making requests to the server. I also used the Grpc.Net.Client-GrpcChannelProviderHost in the InitialSettings.cs.

RpcException: Status(StatusCode="Internal", Detail="Error starting gRPC call. HttpRequestException: An error occurred while sending the request WebException: Error getting response stream (ReadDoneAsync2): ReceiveFailure", DebugException="System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error getting response stream (ReadDoneAsync2): ReceiveFailure
  at System.Net.WebResponseStream.InitReadAsync (System.Threading.CancellationToken cancellationToken) [0x000f3] in <bbae6af52a2a4bd982f8fde9721d2c3b>:0 
  at System.Net.WebOperation.Run () [0x001d9] in <bbae6af52a2a4bd982f8fde9721d2c3b>:0 
  at System.Net.WebCompletionSource`1[T].WaitForCompletion () [0x00094] in <bbae6af52a2a4bd982f8fde9721d2c3b>:0 
  at System.Net.HttpWebRequest.RunWithTimeoutWorker[T] (System.Threading.Tasks.Task`1[TResult] workerTask, System.Int32 timeout, System.Action abort, System.Func`1[TResult] aborted, System.Threading.CancellationTokenSource cts) [0x000f8] in <bbae6af52a2a4bd982f8fde9721d2c3b>:0 
  at System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x00020] in <bbae6af52a2a4bd982f8fde9721d2c3b>:0 
  at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func`2[T,TResult] endFunction, System.Action`1[T] endAction, System.Threading.Tasks.Task`1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in <e40e5a8f982c4b618a930d29f9bd091c>:0 
--- End of stack trace from previous location where exception was thrown ---

  at System.Net.Http.MonoWebRequestHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x004ae] in <853a2350e6f2416eb8e7fe05624a86b6>:0 
   --- End of inner exception stack trace ---
  at System.Net.Http.MonoWebRequestHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00509] in <853a2350e6f2416eb8e7fe05624a86b6>:0 
  at Grpc.Net.Client.Internal.GrpcCall`2[TRequest,TResponse].RunCall (System.Net.Http.HttpRequestMessage request, System.Nullable`1[T] timeout) [0x00215] in <7e0ae11247164b03889de8583a72a101>:0 ")
MagicOnion.Client.ResponseContext`1[T].Deserialize () (at Assets/Scripts/MagicOnion/MagicOnion.Client/ClientFilter.cs:161)
MagicOnion.UnaryResult`1[TResponse].UnwrapResponse () (at Assets/Scripts/MagicOnion/MagicOnion.Abstractions/UnaryResult.cs:116)
AccountService.UpdateClientAsync () (at Assets/Scripts/AccountService.cs:128)

I didn't modify the server-side-code, which was working while testing with the Grpc.Core Libary. (Currently I am using BestHTTP/2 because my Android-Build kept crashing before). Is there anything I am missing? Thank you for the great framework!

@59-36
Copy link

59-36 commented Dec 30, 2022

I figured it out! It just had something to do with the way I was using the TLS/SSL Certificate and the port I defined in Kestrel (oops). Now the UnaryCalls work as expected! The only issue that I am facing now is that the StreamingHubs are not working correctly.

This is the error message I get whenever it tries to connect:

Grpc.Core.RpcException: Status(StatusCode="Internal", Detail="The request started successfully (StatusCode = OK), but the StreamingHub client has failed to negotiate with the server.")
  at MagicOnion.Client.StreamingHubClientBase`2[TStreamingHub,TReceiver].__ConnectAndSubscribeAsync (TReceiver receiver, System.Threading.CancellationToken cancellationToken) [0x0031a] in [MyProject]\Assets\Scripts\MagicOnion\MagicOnion.Client\StreamingHubClientBase.cs:106 

On the Server-Side the following error is given:

System.IO.IOException: The request stream was aborted.
       ---> Microsoft.AspNetCore.Connections.ConnectionAbortedException: The HTTP/2 connection faulted.
         --- End of inner exception stack trace ---
         at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
         at System.IO.Pipelines.Pipe.GetReadAsyncResult()
         at System.IO.Pipelines.Pipe.DefaultPipeReader.GetResult(Int16 token)
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.Http2MessageBody.ReadAsync(CancellationToken cancellationToken)
         at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
         at Grpc.AspNetCore.Server.Internal.PipeExtensions.ReadStreamMessageAsync[T](PipeReader input, HttpContextServerCallContext serverCallContext, Func`2 deserializer, CancellationToken cancellationToken)

Here is the logs from Best HTTP2:

{"tid":1,"div":"RequestEventHelper","msg":"Enqueue request event: [RequestEventInfo SourceRequest: https:\/\/localhost:5001\/IChatHub\/Connect, Event: StateChange, State: Queued]","stack":"  at Core.RequestEventHelper.EnqueueRequestEvent (Core.RequestEventInfo event) [0x00012] 

{"tid":1,"div":"RequestEventHelper","msg":"Enqueue request event: [RequestEventInfo SourceRequest: https:\/\/localhost:5001\/IChatHub\/Connect, Event: Resend]","stack":"  at Core.RequestEventHelper.EnqueueRequestEvent (Core.RequestEventInfo event) [0x00012]

{"tid":1,"div":"RequestEventHelper","msg":"Processing request event: [RequestEventInfo SourceRequest: https:\/\/localhost:5001\/IChatHub\/Connect, Event: StateChange, State: Queued]","stack":"  at Core.RequestEventHelper.ProcessQueue () [0x0001f] 

{"tid":1,"div":"RequestEventHelper","msg":"Processing request event: [RequestEventInfo SourceRequest: https:\/\/localhost:5001\/IChatHub\/Connect, Event: Resend]","stack":"  at Core.RequestEventHelper.ProcessQueue () [0x0001f] 

{"tid":1,"div":"ProxyDetector","msg":"OnRequestEvent(RequestEvents.Resend) uri: 'https:\/\/localhost:5001\/IChatHub\/Connect'","stack":"  at Proxies.Autodetect.ProxyDetector.OnRequestEvent (Core.RequestEventInfo event) [0x0002f] 

{"tid":1,"div":"ProxyDetector","msg":"Calling ProgrammaticallyAddedProxyDetector's GetProxy","stack":"  at Proxies.Autodetect.ProxyDetector.OnRequestEvent (Core.RequestEventInfo event) [0x00090] 

{"tid":1,"div":"ProxyDetector","msg":"Calling EnvironmentProxyDetector's GetProxy","stack":"  at Proxies.Autodetect.ProxyDetector.OnRequestEvent (Core.RequestEventInfo event) [0x00090]

{"tid":1,"div":"EnvironmentProxyDetector","msg":"GetProxy - HTTPS_PROXY: ''","stack":"  at Proxies.Autodetect.EnvironmentProxyDetector.Proxies.Autodetect.IProxyDetector.GetProxy (HTTPRequest request) [0x0003a]

{"tid":1,"div":"ProxyDetector","msg":"Calling FrameworkProxyDetector's GetProxy","stack":"  at Proxies.Autodetect.ProxyDetector.OnRequestEvent (Core.RequestEventInfo event) [0x00090] 

{"tid":1,"div":"ProxyDetector","msg":"No Proxy for 'https:\/\/localhost:5001\/IChatHub\/Connect'.","stack":"  at Proxies.Autodetect.ProxyDetector.OnRequestEvent (Core.RequestEventInfo event) [0x001bd]

{"tid":1,"div":"RequestEventHelper","msg":"Enqueue request event: [RequestEventInfo SourceRequest: https:\/\/localhost:5001\/IChatHub\/Connect, Event: StateChange, State: Initial]","stack":"  at Core.RequestEventHelper.EnqueueRequestEvent (Core.RequestEventInfo event) [0x00012] 

{"tid":1,"div":"HostConnection","msg":"GetNextAvailable - returning with connection. state: Processing, CanProcessMultiple: True","stack":"  at Core.HostConnection.GetNextAvailable (HTTPRequest request) [0x0008c] 

{"tid":1,"div":"RequestEventHelper","msg":"Enqueue request event: [RequestEventInfo SourceRequest: https:\/\/localhost:5001\/IChatHub\/Connect, Event: StateChange, State: Processing]","stack":"  at Core.RequestEventHelper.EnqueueRequestEvent (Core.RequestEventInfo event) [0x00012] 

{"tid":1,"div":"HTTP2Handler","msg":"Process request called","stack":"  at Connections.HTTP2.HTTP2Handler.Process (HTTPRequest request) [0x00001]

{"tid":1,"div":"RequestEventHelper","msg":"Processing request event: [RequestEventInfo SourceRequest: https:\/\/localhost:5001\/IChatHub\/Connect, Event: StateChange, State: Initial]","stack":"  at Core.RequestEventHelper.ProcessQueue () [0x0001f] 

{"tid":1,"div":"RequestEventHelper","msg":"Processing request event: [RequestEventInfo SourceRequest: https:\/\/localhost:5001\/IChatHub\/Connect, Event: StateChange, State: Processing]","stack":"  at Core.RequestEventHelper.ProcessQueue () [0x0001f]

{"tid":690,"div":"RequestEventHelper","msg":"Enqueue request event: [RequestEventInfo SourceRequest: https:\/\/localhost:5001\/IChatHub\/Connect, Event: TimingData, Name: Queued, Time: 30.12.2022 15:12:51]","stack":"  at Core.RequestEventHelper.EnqueueRequestEvent (Core.RequestEventInfo event) [0x00012] 

{"tid":690,"div":"HTTP2Stream","msg":"[13] Request assigned to stream. Remote Window: 98.304. Uri: https:\/\/localhost:5001\/IChatHub\/Connect","stack":"  at Connections.HTTP2.HTTP2Stream.Assign (HTTPRequest request) [0x0002f]

{"tid":690,"div":"HPACKEncoder","msg":"[13] - Encode - Header(1\/1): 'user-agent': 'grpc-dotnet\/2.50.0 (Mono 6.13.0; CLR 4.0.30319.42000; netstandard2.1; windows; x64)'","stack":"  at Connections.HTTP2.HPACKEncoder+<>c__DisplayClass5_1.<Encode>b__0 (System.String header, System.Collections.Generic.List`1[T] values) [0x000c5]

{"tid":690,"div":"HPACKEncoder","msg":"[13] - Encode - Header(1\/1): 'grpc-accept-encoding': 'identity,gzip'","stack":"  at Connections.HTTP2.HPACKEncoder+<>c__DisplayClass5_1.<Encode>b__0 (System.String header, System.Collections.Generic.List`1[T] values) [0x000c5]

{"tid":690,"div":"HPACKEncoder","msg":"[13] - Encode - Header(1\/1): 'authorization': 'Bearer here-is-my-encoded-token'","stack":"  at Connections.HTTP2.HPACKEncoder+<>c__DisplayClass5_1.<Encode>b__0 (System.String header, System.Collections.Generic.List`1[T] values) [0x000c5]

{"tid":690,"div":"HPACKEncoder","msg":"[13] - Encode - Header(1\/1): 'content-type': 'application\/grpc'","stack":"  at Connections.HTTP2.HPACKEncoder+<>c__DisplayClass5_1.<Encode>b__0 (System.String header, System.Collections.Generic.List`1[T] values) [0x000c5]

{"tid":1,"div":"RequestEventHelper","msg":"Processing request event: [RequestEventInfo SourceRequest: https:\/\/localhost:5001\/IChatHub\/Connect, Event: TimingData, Name: Queued, Time: 30.12.2022 15:12:51]","stack":"  at Core.RequestEventHelper.ProcessQueue () [0x0001f]

{"tid":690,"div":"HPACKEncoder","msg":"[13] - Encode - Header(1\/1): 'accept-encoding': 'gzip, br, identity'","stack":"  at Connections.HTTP2.HPACKEncoder+<>c__DisplayClass5_1.<Encode>b__0 (System.String header, System.Collections.Generic.List`1[T] values) [0x000c5] 

{"tid":690,"div":"HTTP2Stream","msg":"[13] State changed from Idle to Open","stack":"  at Connections.HTTP2.HTTP2Stream.set_State (Connections.HTTP2.HTTP2StreamStates value) [0x00020]

{"tid":690,"div":"HTTP2Handler","msg":"Sending frame: [HTTP2FrameHeaderAndPayload Length: 9, Type: HEADERS, Flags: 00000100, StreamId: 13, PayloadOffset: 0, DontUseMemPool: False, Payload: [BufferSegment Offset: 0 Count: 9 Data: [83, BE, C7, 87, C6, C5, C4, C3, C2]]]","stack":"  at Connections.HTTP2.HTTP2Handler.RunHandler () [0x00975]

{"tid":691,"div":"HTTP2Handler","msg":"New frame received: [HTTP2FrameHeaderAndPayload Length: 35, Type: HEADERS, Flags: 00000100, StreamId: 13, PayloadOffset: 0, DontUseMemPool: False, Payload: [BufferSegment Offset: 0 Count: 35 Data: [88, C6, 61, 1D, 46, 72, 69, 2C, 20, 33, 30, 20, 44, 65, 63, 20, 32, 30, 32, 32, 20, 31, 34, 3A, 31, 32, 3A, 35, 30, 20, 47, 4D, 54, C5, C0]]]","stack":"  at Connections.HTTP2.HTTP2Handler.ReadThread () [0x00063]

{"tid":690,"div":"HTTP2Stream","msg":"[13] Process - processing frame: [HTTP2FrameHeaderAndPayload Length: 35, Type: HEADERS, Flags: 00000100, StreamId: 13, PayloadOffset: 0, DontUseMemPool: False, Payload: [BufferSegment Offset: 0 Count: 35 Data: [88, C6, 61, 1D, 46, 72, 69, 2C, 20, 33, 30, 20, 44, 65, 63, 20, 32, 30, 32, 32, 20, 31, 34, 3A, 31, 32, 3A, 35, 30, 20, 47, 4D, 54, C5, C0]]]","stack":"  at Connections.HTTP2.HTTP2Stream.ProcessIncomingFrames (System.Collections.Generic.List`1[T] outgoingFrames) [0x00074]

{"tid":690,"div":"RequestEventHelper","msg":"Enqueue request event: [RequestEventInfo SourceRequest: https:\/\/localhost:5001\/IChatHub\/Connect, Event: TimingData, Name: Waiting (TTFB), Time: 30.12.2022 15:12:51]","stack":"  at Core.RequestEventHelper.EnqueueRequestEvent (Core.RequestEventInfo event) [0x00012] 

{"tid":690,"div":"HPACKEncoder","msg":"[13] Decode - IndexedHeader: [:status, 200]","stack":"  at Connections.HTTP2.HPACKEncoder.Decode (Connections.HTTP2.HTTP2Stream context, System.IO.Stream stream, System.Collections.Generic.List`1[T] to) [0x0003f]

{"tid":690,"div":"HPACKEncoder","msg":"[13] Decode - IndexedHeader: [content-type, application\/grpc]","stack":"  at Connections.HTTP2.HPACKEncoder.Decode (Connections.HTTP2.HTTP2Stream context, System.IO.Stream stream, System.Collections.Generic.List`1[T] to) [0x0003f]

{"tid":690,"div":"HPACKEncoder","msg":"[13] Decode - LiteralHeaderFieldWithIncrementalIndexing_IndexedName: [date, Fri, 30 Dec 2022 14:12:50 GMT]","stack":"  at Connections.HTTP2.HPACKEncoder.Decode (Connections.HTTP2.HTTP2Stream context, System.IO.Stream stream, System.Collections.Generic.List`1[T] to) [0x00171]

{"tid":1,"div":"RequestEventHelper","msg":"Processing request event: [RequestEventInfo SourceRequest: https:\/\/localhost:5001\/IChatHub\/Connect, Event: TimingData, Name: Waiting (TTFB), Time: 30.12.2022 15:12:51]","stack":"  at Core.RequestEventHelper.ProcessQueue () [0x0001f] 

{"tid":690,"div":"HPACKEncoder","msg":"[13] Decode - IndexedHeader: [server, Kestrel]","stack":"  at Connections.HTTP2.HPACKEncoder.Decode (Connections.HTTP2.HTTP2Stream context, System.IO.Stream stream, System.Collections.Generic.List`1[T] to) [0x0003f]

{"tid":690,"div":"HPACKEncoder","msg":"[13] Decode - IndexedHeader: [x-magiconion-streaminghub-version, 2]","stack":"  at Connections.HTTP2.HPACKEncoder.Decode (Connections.HTTP2.HTTP2Stream context, System.IO.Stream stream, System.Collections.Generic.List`1[T] to) [0x0003f]

{"tid":690,"div":"RequestEventHelper","msg":"Enqueue request event: [RequestEventInfo SourceRequest: https:\/\/localhost:5001\/IChatHub\/Connect, Event: TimingData, Name: Headers, Time: 30.12.2022 15:12:51]","stack":"  at Core.RequestEventHelper.EnqueueRequestEvent (Core.RequestEventInfo event) [0x00012] 

{"tid":690,"div":"RequestEventHelper","msg":"Enqueue request event: [RequestEventInfo SourceRequest: https:\/\/localhost:5001\/IChatHub\/Connect, Event: Headers]","stack":"  at Core.RequestEventHelper.EnqueueRequestEvent (Core.RequestEventInfo event) [0x00012]

{"tid":690,"div":"RequestEventHelper","msg":"Enqueue request event: [RequestEventInfo SourceRequest: https:\/\/localhost:5001\/IChatHub\/Connect, Event: StreamingData, DataLength: 9]","stack":"  at Core.RequestEventHelper.EnqueueRequestEvent (Core.RequestEventInfo event) [0x00012] 

{"tid":690,"div":"HTTPResponse","msg":"AddStreamedFragment buffer length: 9 UnprocessedFragments: 1","stack":"  at HTTPResponse.VerboseLogging (System.String str) [0x00012]

I know this thread might be getting a little long, so let me know if I should create a new issue instead and if any additional information is needed.

@mayuki
Copy link
Member

mayuki commented Jan 4, 2023

@FreshL4ma
Thank you. We have not tested the behavior with BestHTTP/2 and gRPC handlers at this time.

Since Unary is working, there seems to be an incompatible behavior in Streaming.
We cannot promise support, but we would appreciate it if you could report this as a separate issue.

@mayuki
Copy link
Member

mayuki commented Jun 26, 2023

Watch for future updates to be posted in #661.

@mayuki mayuki closed this as completed Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants