Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 增加Google PubSub的截止时间超时_C#_.net_Google Cloud Pubsub - Fatal编程技术网

C# 增加Google PubSub的截止时间超时

C# 增加Google PubSub的截止时间超时,c#,.net,google-cloud-pubsub,C#,.net,Google Cloud Pubsub,在使用C#库向Google PubSub主题发布消息时,我们会间歇性地遇到以下错误: Exception: Grpc.Core.RpcException: Status(StatusCode=Unauthenticated, Detail="Deadline Exceeded") at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.Ta

在使用C#库向Google PubSub主题发布消息时,我们会间歇性地遇到以下错误:

Exception: Grpc.Core.RpcException: Status(StatusCode=Unauthenticated, Detail="Deadline Exceeded")
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Google.Api.Gax.Grpc.ApiCallRetryExtensions.<>c__DisplayClass0_0`2.<<WithRetry>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Google.Cloud.PubSub.V1.Tasks.ForwardingAwaiter`1.GetResult()
   at Google.Cloud.PubSub.V1.Tasks.Extensions.<>c__DisplayClass6_0`1.<<ConfigureAwaitHideErrors>g__Inner0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Google.Cloud.PubSub.V1.Tasks.ForwardingAwaiter`1.GetResult()
   at Google.Cloud.PubSub.V1.SimplePublisherImpl.<PublishAsync>d__26.MoveNext()
   at Google.Api.Gax.Grpc.ApiCallRetryExtensions.<>c__DisplayClass0_0`2.<<WithRetry>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---

有人知道如何在此配置中配置截止日期阈值吗?这是使用
Google.Cloud.PubSub.V1
客户端库nuget包的
1.0.0-beta13

这似乎是通过将
PublisherSettings
对象传递到
PublisherClient.Create
调用来控制的

private SimplePublisher CreateSimplePublisher(int maxItems, int maxSizeBytes, TimeSpan maxDelay)
{
    var credential = Credential.IsCreateScopedRequired ?
        Credential.CreateScoped(PublisherClient.DefaultScopes) : Credential;
    var channel = new Channel(
        PublisherClient.DefaultEndpoint.Host,
        PublisherClient.DefaultEndpoint.Port,
        credential.ToChannelCredentials());
    //Add a specific timeout for the publish operation
    var publisherClientSettings = new PublisherSettings
    {
        PublishSettings = CallSettings.FromCallTiming(CallTiming.FromTimeout(TimeSpan.FromMinutes(60)))
    };
    var publisherClient = PublisherClient.Create(channel,publisherClientSettings);
    return SimplePublisher.Create(
        new TopicName(Project, Topic),
        new[] { publisherClient },
        new SimplePublisher.Settings
        {
            BatchingSettings = new BatchingSettings
            (
                elementCountThreshold: maxItems,
                byteCountThreshold: maxSizeBytes,
                delayThreshold: maxDelay
            )
        });
}

如果从1.0.0-beta15更改为1.0.0-beta16,是否有更新的答案:“PublisherSettings现在命名为PublisherServiceAppSettings”?
private SimplePublisher CreateSimplePublisher(int maxItems, int maxSizeBytes, TimeSpan maxDelay)
{
    var credential = Credential.IsCreateScopedRequired ?
        Credential.CreateScoped(PublisherClient.DefaultScopes) : Credential;
    var channel = new Channel(
        PublisherClient.DefaultEndpoint.Host,
        PublisherClient.DefaultEndpoint.Port,
        credential.ToChannelCredentials());
    //Add a specific timeout for the publish operation
    var publisherClientSettings = new PublisherSettings
    {
        PublishSettings = CallSettings.FromCallTiming(CallTiming.FromTimeout(TimeSpan.FromMinutes(60)))
    };
    var publisherClient = PublisherClient.Create(channel,publisherClientSettings);
    return SimplePublisher.Create(
        new TopicName(Project, Topic),
        new[] { publisherClient },
        new SimplePublisher.Settings
        {
            BatchingSettings = new BatchingSettings
            (
                elementCountThreshold: maxItems,
                byteCountThreshold: maxSizeBytes,
                delayThreshold: maxDelay
            )
        });
}