1

我正在使用 Google 自定义指标将自定义指标写入云。我的代码如下所示:

var client = MetricServiceClient.Create();
// ... 
client.CreateTimeSeries(name, timeSeries);

当我在我的机器上运行它时,它工作得很好。

当我在生产中运行它时,它运行良好,直到停止。我收到此错误消息:

Grpc.Core.RpcException: Status(StatusCode=Unavailable, Detail="Transport closed")
   at Grpc.Core.Internal.AsyncCall`2.UnaryCall(TRequest msg)
   at Grpc.Core.DefaultCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method`2 method, String host, CallOptions options, TRequest request)
   at Grpc.Core.Interceptors.InterceptingCallInvoker.<BlockingUnaryCall>b__3_0[TRequest,TResponse](TRequest req, ClientInterceptorContext`2 ctx)
   at Grpc.Core.ClientBase.ClientBaseConfiguration.ClientBaseConfigurationInterceptor.BlockingUnaryCall[TRequest,TResponse](TRequest request, ClientInterceptorContext`2 context, BlockingUnaryCallContinuation`2 continuation)
   at Grpc.Core.Interceptors.InterceptingCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method`2 method, String host, CallOptions options, TRequest request)
   at Google.Cloud.Monitoring.V3.MetricService.MetricServiceClient.CreateTimeSeries(CreateTimeSeriesRequest request, CallOptions options)
   at Google.Api.Gax.Grpc.ApiCall.GrpcCallAdapter`2.CallSync(TRequest request, CallSettings callSettings)
   at Google.Api.Gax.Grpc.ApiCallRetryExtensions.<>c__DisplayClass1_0`2.<WithRetry>b__0(TRequest request, CallSettings callSettings)
   at Google.Cloud.Monitoring.V3.MetricServiceClientImpl.CreateTimeSeries(CreateTimeSeriesRequest request, CallSettings callSettings)
   at XXX in XXX.cs:line 90

或类似的错误:

Grpc.Core.RpcException: Status(StatusCode=Unavailable, Detail="Socket closed")
   at Grpc.Core.Internal.AsyncCall`2.UnaryCall(TRequest msg)
   at Grpc.Core.DefaultCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method`2 method, String host, CallOptions options, TRequest request)
   at Grpc.Core.Interceptors.InterceptingCallInvoker.<BlockingUnaryCall>b__3_0[TRequest,TResponse](TRequest req, ClientInterceptorContext`2 ctx)
   at Grpc.Core.ClientBase.ClientBaseConfiguration.ClientBaseConfigurationInterceptor.BlockingUnaryCall[TRequest,TResponse](TRequest request, ClientInterceptorContext`2 context, BlockingUnaryCallContinuation`2 continuation)
   at Grpc.Core.Interceptors.InterceptingCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method`2 method, String host, CallOptions options, TRequest request)
   at Google.Cloud.Monitoring.V3.MetricService.MetricServiceClient.CreateTimeSeries(CreateTimeSeriesRequest request, CallOptions options)
   at Google.Api.Gax.Grpc.ApiCall.GrpcCallAdapter`2.CallSync(TRequest request, CallSettings callSettings)
   at Google.Api.Gax.Grpc.ApiCallRetryExtensions.<>c__DisplayClass1_0`2.<WithRetry>b__0(TRequest request, CallSettings callSettings)
   at Google.Cloud.Monitoring.V3.MetricServiceClientImpl.CreateTimeSeries(CreateTimeSeriesRequest request, CallSettings callSettings)

这个错误不时重复。它看起来有 99% 的时间都在工作。

这里有什么问题?如何解决?

4

0 回答 0