Reputation: 5455
We're intermittently getting the following errors when publishing messages to Google PubSub topics when using the C# libraries:
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 ---
Which Google tells me is a configurable timeout. We're configuring the client libraries like so:
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());
var publisherClient = PublisherClient.Create(channel);
return SimplePublisher.Create(
new TopicName(Project, Topic),
new[] { publisherClient },
new SimplePublisher.Settings
{
BatchingSettings = new BatchingSettings
(
elementCountThreshold: maxItems,
byteCountThreshold: maxSizeBytes,
delayThreshold: maxDelay
)
});
}
Does anyone know how to configure the deadline threshold in this configuration? This is using version 1.0.0-beta13
of the Google.Cloud.PubSub.V1
client libraries nuget package.
Upvotes: 2
Views: 977
Reputation: 5455
This appears to be controlled by passing a PublisherSettings
object to the PublisherClient.Create
call.
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
)
});
}
Upvotes: 2