question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error starting gRPC call. A task was canceled.

See original GitHub issue

When I am doing grpc call, after some time this exception throws “Error starting gRPC call. A task was canceled.”

.net 6

Exception

{ “@timestamp”: “2022-03-30T12:37:38.5892808+04:00”, “level”: “Error”, “messageTemplate”: “Error starting gRPC call.”, “message”: “Error starting gRPC call.”, “exceptions”: [ { “Depth”: 0, “ClassName”: “System.Threading.Tasks.TaskCanceledException”, “Message”: “A task was canceled.”, “Source”: “System.Private.CoreLib”, “StackTraceString”: " at Grpc.Net.Client.Balancer.Internal.ConnectionManager.GetNextPickerAsync(CancellationToken cancellationToken)\n at Grpc.Net.Client.Balancer.Internal.ConnectionManager.PickAsync(PickContext context, Boolean waitForReady, CancellationToken cancellationToken)\n at Grpc.Net.Client.Balancer.Internal.BalancerHttpHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\n at Grpc.Net.Client.Internal.GrpcCall2.RunCall(HttpRequestMessage request, Nullable1 timeout)", “RemoteStackTraceString”: null, “RemoteStackIndex”: 0, “HResult”: -2146233029, “HelpURL”: null } ], “fields”: { “EventId”: { “Id”: 6, “Name”: “ErrorStartingCall” }, “SourceContext”: “Grpc.Net.Client.Internal.GrpcCall”, “GrpcMethodType”: “Unary”, “GrpcUri”: “/XXXXX/Get”, } }

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:23 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
vladislav-prishchepacommented, Apr 7, 2022

I’ve repeated tests with 2.45.0-pre1 - everything works well. @JamesNK Thanks for fix

1reaction
BenVcommented, Apr 13, 2022

This is from a production service so I am unable to turn on debug logging (I’ll try to reproduce in staging/locally, but it seems to happen only under load so far). Here is the stack trace, if it is helpful:

Type: Grpc.Core.RpcException
	Source: Grpc.Net.Client.Balancer.Internal.ConnectionManager+<PickAsync>d__45, Grpc.Net.Client, Version=2.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad
	Message: Status(StatusCode="Unavailable", Detail="Error connecting to subchannel.", DebugException="System.InvalidOperationException: An attempt was made to transition a task to a final state when it had already completed.
   at Grpc.Net.Client.Balancer.Internal.ConnectionManager.UpdateState(BalancerState state)
   at Grpc.Net.Client.Balancer.Internal.ChildHandlerLoadBalancer.ChildHandlerController.UpdateState(BalancerState state)
   at Grpc.Net.Client.Balancer.PickFirstBalancer.UpdateSubchannelState(Subchannel subchannel, SubchannelState state)
   at Grpc.Net.Client.Balancer.Subchannel.RaiseStateChanged(ConnectivityState state, Status status)
   at Grpc.Net.Client.Balancer.Internal.ConnectionManager.OnSubchannelStateChange(Subchannel subchannel, ConnectivityState state, Status status)
   at Grpc.Net.Client.Balancer.Subchannel.UpdateConnectivityState(ConnectivityState state, Status status)
   at Grpc.Net.Client.Balancer.Internal.SocketConnectivitySubchannelTransport.TryConnectAsync(CancellationToken cancellationToken)")
	Trace:    at Grpc.Net.Client.Balancer.Internal.ConnectionManager.PickAsync(PickContext context, Boolean waitForReady, CancellationToken cancellationToken)
   at Grpc.Net.Client.Balancer.Internal.BalancerHttpHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at Grpc.Net.Client.Internal.GrpcCall`2.RunCall(HttpRequestMessage request, Nullable`1 timeout)
Read more comments on GitHub >

github_iconTop Results From Across the Web

gRPC: Random CANCELLED exception on RPC calls
Client sends a message and server receives it without problem. But this call occasionally gives me an error: io.grpc.StatusRuntimeException: ...
Read more >
Reliable gRPC services with deadlines and cancellation
A deadline allows a gRPC client to specify how long it will wait for a call to complete. When a deadline is exceeded,...
Read more >
Just because you stopped waiting for it, doesn't mean the ...
Namely, that even if the WaitAsync() call is cancelled or times-out, the original Task continues running in the background.
Read more >
Cancellation
When a gRPC client is no longer interested in the result of an RPC call, it may cancel to signal this discontinuation of...
Read more >
GRPC issues between servers
We allocate a gRPC dynamic port when opening communication between external processes (like pwsh\powershell) and the PSU service. A cancelled ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found