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

Client can't detect that connection is closed by server #2164

Closed
ValeryYegorov opened this issue Jun 15, 2023 · 2 comments
Closed

Client can't detect that connection is closed by server #2164

ValeryYegorov opened this issue Jun 15, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@ValeryYegorov
Copy link

What version of gRPC and what language are you using?

Grpc.AspNetCore.Server Version="2.54.0-pre1"

What operating system (Linux, Windows,...) and version?

Linux Amazon Linux 2 - 5.10.179-168.710.amzn2.x86_64
Microsoft Windows Server 2022 Datacenter - 10.0.20348 N/A Build 20348

What runtime / compiler are you using (e.g. .NET Core SDK version dotnet --info)

Host:
Version: 8.0.0-preview.5.23280.8
Architecture: x64
Commit: bc78804f5d
.NET SDKs installed:
3.1.426 [/usr/share/dotnet/sdk]
7.0.304 [/usr/share/dotnet/sdk]
8.0.100-preview.4.23260.5 [/usr/share/dotnet/sdk]
8.0.100-preview.5.23303.2 [/usr/share/dotnet/sdk]

What did you do?

  1. Client (Ios mobile application using cronet) connect to server (Microsoft Windows or Linux)
  2. do some actions
  3. reset stream
  4. Client application goes to background (it can't handle/ process receiving or sending any packets)
  5. after 20 seconds client restores from background and try to create stream on the same connection.

Server don't answer anything.

What did you expect to see?

Server should inform client that connection is closed.

What did you see instead?

When client sends request to server on a closed (on server side) connection, server returns nothing, until client idleTimeout not finished.
Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

In attached file you can see msquic trace from WindowsServer with that issue

quic-cleaned.txt

Same issue opened on microsoft/msquic#3703

@ValeryYegorov
Copy link
Author

Additional information
Client send idle_timeout=120sec to server
Kestrel server has

serverOptions.ListenAnyIP(1189, o =>
{
    o.Protocols = HttpProtocols.Http1AndHttp2AndHttp3;
    o.KestrelServerOptions.Limits.KeepAliveTimeout = TimeSpan.FromSeconds(120);
    .......
}

In console trace we see:

[20:59:01.0502] trce: Grpc.AspNetCore.Server.ServerCallHandler[18]
      Serialized 'MobileAppAPI.NetCore.gRPC.Protos.v3.ClientNotification' to 2 byte message.
[20:59:01.0523] trce: Grpc.AspNetCore.Server.ServerCallHandler[19]
      Compressing message with 'gzip' encoding.
[20:59:01.0545] trce: Microsoft.AspNetCore.Server.Kestrel.Http3[47]
      Connection id "0HMRDSDBPA405" sending DATA frame for stream ID 0 with length 27.
[20:59:01.0566] trce: Grpc.AspNetCore.Server.ServerCallHandler[16]
      Message sent.
[20:59:06.2297] dbug: Microsoft.AspNetCore.Server.Kestrel.Http3[45]
      Trace id "0HMRDSDBPA405:00000000": HTTP/3 stream error "H3_REQUEST_CANCELLED". An abort is being sent to the stream.
      Microsoft.AspNetCore.Connections.ConnectionAbortedException: The client reset the request stream.
       ---> System.IO.IOException: The client reset the request stream.
         --- End of inner exception stack trace ---
[20:59:06.2352] info: Grpc.AspNetCore.Server.ServerCallHandler[14]
      Error reading message.
      System.IO.IOException: The client reset the request stream.
         at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
         at System.IO.Pipelines.Pipe.GetReadAsyncResult()
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http3.Http3MessageBody.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)
[20:59:06.3168] trce: Grpc.AspNetCore.Server.ServerCallHandler[27]
      Request deadline stopped.
[20:59:22.4109] dbug: Microsoft.AspNetCore.Server.Kestrel.Http3[53]
      Connection id "0HMRDSDBPA405": GOAWAY stream ID 8.
[20:59:22.4148] trce: Microsoft.AspNetCore.Server.Kestrel.Http3[47]
      Connection id "0HMRDSDBPA405" sending GOAWAY frame for stream ID 3 with length 1.
[20:59:22.4250] dbug: Microsoft.AspNetCore.Server.Kestrel.Http3[44]
      Connection id "0HMRDSDBPA405" is closed. The last processed stream ID was 4.

Delay between H3_REQUEST_CANCELLED and GOAWAY is around 16 sec

@JamesNK
Copy link
Member

JamesNK commented Jun 20, 2023

I don't think this is a bug in gRPC. The issue will be located in Kestrel, or System.Net.Quic, or msquic.

@JamesNK JamesNK closed this as completed Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants