googleads / google-ads-dotnet

This project hosts the .NET client library for the Google Ads API.
https://developers.google.com/google-ads/api
Apache License 2.0
72 stars 95 forks source link

grpc Exception on ConfigurationLoadCredential .Net 7 #531

Open zgf opened 1 year ago

zgf commented 1 year ago

My google ads dotnet SDK sends two create customer client requests to the google ads server via gprc, but the second request always crashes with Rpc Exception :

  "Exception": "System.AggregateException: One or more errors occurred. (Status(StatusCode=\"Unavailable\", Detail=\"Error starting gRPC call. HttpRequestException: An internal error has occurred. ConfigurationLoadCredential failed: Unknown (0x80090331) (googleads.googleapis.com:443) QuicException: An internal error has occurred. ConfigurationLoadCredential failed: Unknown (0x80090331)\", DebugException=\"System.Net.Http.HttpRequestException: An internal error has occurred. ConfigurationLoadCredential failed: Unknown (0x80090331) (googleads.googleapis.com:443)\r\n ---> System.Net.Quic.QuicException: An internal error has occurred. ConfigurationLoadCredential failed: Unknown (0x80090331)\r\n
   at System.Net.Quic.ThrowHelper.ThrowIfMsQuicError(Int32 status, String message)\r\n
   at System.Net.Quic.MsQuicConfiguration.Create(QuicConnectionOptions options, QUIC_CREDENTIAL_FLAGS flags, X509Certificate certificate, X509Certificate[] intermediates, List`1 alpnProtocols, CipherSuitesPolicy cipherSuitesPolicy, EncryptionPolicy encryptionPolicy)\r\n
   at System.Net.Quic.MsQuicConfiguration.Create(QuicClientConnectionOptions options)\r\n
   at System.Net.Quic.QuicConnection.FinishConnectAsync(QuicClientConnectionOptions options, CancellationToken cancellationToken)\r\n
   at System.Net.Quic.QuicConnection.ConnectAsync(QuicClientConnectionOptions options, CancellationToken cancellationToken)\r\n
   at System.Net.Quic.QuicConnection.ConnectAsync(QuicClientConnectionOptions options, CancellationToken cancellationToken)\r\n
   at System.Net.Http.ConnectHelper.ConnectQuicAsync(HttpRequestMessage request, DnsEndPoint endPoint, TimeSpan idleTimeout, SslClientAuthenticationOptions clientAuthenticationOptions, CancellationToken cancellationToken)\r\n
   --- End of inner exception stack trace ---\r\n
   at System.Net.Http.ConnectHelper.ConnectQuicAsync(HttpRequestMessage request, DnsEndPoint endPoint, TimeSpan idleTimeout, SslClientAuthenticationOptions clientAuthenticationOptions, CancellationToken cancellationToken)\r\n
   at System.Net.Http.HttpConnectionPool.GetHttp3ConnectionAsync(HttpRequestMessage request, HttpAuthority authority, CancellationToken cancellationToken)\r\n
   at System.Net.Http.HttpConnectionPool.TrySendUsingHttp3Async(HttpRequestMessage request, CancellationToken cancellationToken)\r\n
   at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)\r\n
   at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)\r\n
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)\r\n
   at Grpc.Net.Client.Balancer.Internal.BalancerHttpHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n
   at Grpc.Net.Client.Internal.GrpcCall`2.RunCall(HttpRequestMessage request, Nullable`1 timeout)\"))\r\n ---> Grpc.Core.RpcException: Status(StatusCode=\"Unavailable\", Detail=\"Error starting gRPC call. HttpRequestException: An internal error has occurred. ConfigurationLoadCredential failed: Unknown (0x80090331) (googleads.googleapis.com:443) QuicException: An internal error has occurred. ConfigurationLoadCredential failed: Unknown (0x80090331)\", DebugException=\"System.Net.Http.HttpRequestException: An internal error has occurred. ConfigurationLoadCredential failed: Unknown (0x80090331) (googleads.googleapis.com:443)\r\n ---> System.Net.Quic.QuicException: An internal error has occurred. ConfigurationLoadCredential failed: Unknown (0x80090331)\r\n
   at System.Net.Quic.ThrowHelper.ThrowIfMsQuicError(Int32 status, String message)\r\n
   at System.Net.Quic.MsQuicConfiguration.Create(QuicConnectionOptions options, QUIC_CREDENTIAL_FLAGS flags, X509Certificate certificate, X509Certificate[] intermediates, List`1 alpnProtocols, CipherSuitesPolicy cipherSuitesPolicy, EncryptionPolicy encryptionPolicy)\r\n
   at System.Net.Quic.MsQuicConfiguration.Create(QuicClientConnectionOptions options)\r\n
   at System.Net.Quic.QuicConnection.FinishConnectAsync(QuicClientConnectionOptions options, CancellationToken cancellationToken)\r\n
   at System.Net.Quic.QuicConnection.ConnectAsync(QuicClientConnectionOptions options, CancellationToken cancellationToken)\r\n
   at System.Net.Quic.QuicConnection.ConnectAsync(QuicClientConnectionOptions options, CancellationToken cancellationToken)\r\n
   at System.Net.Http.ConnectHelper.ConnectQuicAsync(HttpRequestMessage request, DnsEndPoint endPoint, TimeSpan idleTimeout, SslClientAuthenticationOptions clientAuthenticationOptions, CancellationToken cancellationToken)\r\n
   --- End of inner exception stack trace ---\r\n
   at System.Net.Http.ConnectHelper.ConnectQuicAsync(HttpRequestMessage request, DnsEndPoint endPoint, TimeSpan idleTimeout, SslClientAuthenticationOptions clientAuthenticationOptions, CancellationToken cancellationToken)\r\n
   at System.Net.Http.HttpConnectionPool.GetHttp3ConnectionAsync(HttpRequestMessage request, HttpAuthority authority, CancellationToken cancellationToken)\r\n
   at System.Net.Http.HttpConnectionPool.TrySendUsingHttp3Async(HttpRequestMessage request, CancellationToken cancellationToken)\r\n
   at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)\r\n
   at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)\r\n
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)\r\n
   at Grpc.Net.Client.Balancer.Internal.BalancerHttpHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n
   at Grpc.Net.Client.Internal.GrpcCall`2.RunCall(HttpRequestMessage request, Nullable`1 timeout)\")\r\n
   at Grpc.Net.Client.Internal.GrpcCall`2.GetResponseHeadersCoreAsync()\r\n
   --- End of inner exception stack trace ---\r\n
   at Google.Ads.Gax.Interceptors.UnaryRpcInterceptor.<>c__DisplayClass1_0`2.<Intercept>b__0(Task`1 oldTask)\r\n
   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()\r\n
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)\r\n
--- End of stack trace from previous location ---\r\n
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)\r\n
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)\r\n
--- End of stack trace from previous location ---\r\n
   at Google.Api.Gax.Grpc.ApiCall.GrpcCallAdapter`2.<>c__DisplayClass4_0.<<CallAsync>g__WaitAndCallHandlers|0>d.MoveNext()\r\n
--- End of stack trace from previous location ---\r\n
   at Google.Api.Gax.Grpc.ApiCallRetryExtensions.<>c__DisplayClass0_0`2.<<WithRetry>b__0>d.MoveNext()\r\n
--- End of stack trace from previous location ---\r\n
   at Dsp.EntityData.Common.GoogleAccountOperation.CreateGoogleAccountAsync(String managerAccountId, String name, TimeZone timeZone, String currencyCode) in C:\\src\\<projectpath>\\GoogleAccountOperation.cs:line 217\r\n
   at Dsp.EntityData.Common.GoogleAccountOperation.GetPermissionForAdAccountAsync(RequestContext requestContext, String userAccessToken, Account account, ChannelAccountParameters channelAccountParameters, ChannelAccountProperties manageAccountProps) inn C:\\src\\<projectpath>\\GoogleAccountOperation.cs:line 162"

Steps to Reproduce: input parameter: random DescriptiveName, "America/Los_Angeles" TimeZone, USD CurrencyCode. managerAccountId is 5840038648. call method: var response = await _googleClient.CreateCustomerClientAsync(managerAccountId, customer).ConfigureAwait(true);


        public Task<CreateCustomerClientResponse> CreateCustomerClientAsync(string managerCustomerId, Customer customer, CallSettings callSettings = null)
        {
            var customerService = this.Client.GetService(Services.V13.CustomerService);
            return customerService.CreateCustomerClientAsync(managerCustomerId, customer, callSettings);
        }
        var customer = new Customer()
            {
                DescriptiveName = name,
                TimeZone = TimeZoneHelper.GetGoogleTimeZone(timeZone),
                CurrencyCode = currencyCode
            };

Expected behavior: send two calls together. no exception. Client library version and API version: Client library version: Google Ads API version:

 <PackageReference Update="Google.Ads.Common" Version="9.4.0" />
    <PackageReference Update="Google.Ads.GoogleAds" Version="16.1.0" />
    <PackageReference Update="Google.Api.CommonProtos" Version="2.6.0" />
    <PackageReference Update="Google.Api.Gax" Version="4.0.0" />
    <PackageReference Update="Google.Api.Gax.Grpc" Version="4.0.0" />
    <PackageReference Update="Google.Apis" Version="1.56.0" />
    <PackageReference Update="Google.Apis.Auth" Version="1.56.0" />
    <PackageReference Update="Google.Apis.Core" Version="1.56.0" />
    <PackageReference Update="Google.Apis.Oauth2.v2" Version="1.54.0.1869" />
    <PackageReference Update="Google.Apis.TagManager.v2" Version="1.54.0.2417" />
    <PackageReference Update="Google.Protobuf" Version="3.21.9" />
    <PackageReference Update="Google.Apis.MyBusinessAccountManagement.v1" Version="1.54.0.2315" />
    <PackageReference Update="Google.Apis.MyBusinessBusinessInformation.v1" Version="1.54.0.2427" />
    <PackageReference Update="Grpc.Auth" Version="2.46.3" />
    <PackageReference Update="Grpc.Core" Version="2.41.1" />

.NET version: net 7 Operating system (Linux, Windows, ...) and version (if the bug is platform-specific): Windows 11.

Anything else we should know about your project / environment

the first request doesn't crash. Client applications running on Windows 11 On Windows Event Viewer, errors are logged : A fatal error occurred while creating a TLS client credential. The internal error state is 10013.

On Linux docker with the same dotnet core and package versions, no request crashes... It's very strange.

AnashOommen commented 1 year ago

I can explore this later this week.

exile69000 commented 8 months ago

Hi,

I have same issue on windows server 2022 : https://stackoverflow.com/questions/75997420/rpcexception-on-configurationloadcredential-net-7

have you fix this bug ?