You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using StrongGrid 0.98.0. I get 503 error on calling WebhookSettings.GetSignedEventsPublicKeyAsync() in production environment. But it works fine in test environment. On looking at the settings in SendGrid console both environments are setup exactly the same. Any thoughts on what could be the issue?
Exception while executing function: Functions.SendGridCallbackFunction Result: Failure
Exception: System.AggregateException: One or more errors occurred. (503: Service Unavailable)
---> StrongGrid.Utilities.SendGridException: 503: Service Unavailable
at StrongGrid.Utilities.SendGridErrorHandler.OnResponse(IResponse response, Boolean httpErrorAsException)
at Pathoschild.Http.Client.Internal.Request.Execute()
at StrongGrid.Internal.AsObject[T](IRequest request, String propertyName, Boolean throwIfPropertyIsMissing, JsonSerializerOptions options)
at SecureSave.Jobs.WebHooks.SendGridCallbackFunction.Run(HttpRequestData req, FunctionContext executionContext) in D:\a\1\s\SecureSave.Jobs\WebHooks\SendGridCallbackFunction.cs:line 51
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Microsoft.Azure.Functions.Worker.Invocation.DefaultFunctionInvoker`2.<>c.<InvokeAsync>b__6_0(Task`1 t) in D:\a\_work\1\s\src\DotNetWorker.Core\Invocation\DefaultFunctionInvoker.cs:line 32
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.Tasks.Task.<>c.<.cctor>b__273_0(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at Microsoft.Azure.Functions.Worker.Invocation.DefaultFunctionExecutor.ExecuteAsync(FunctionContext context) in D:\a\_work\1\s\src\DotNetWorker.Core\Invocation\DefaultFunctionExecutor.cs:line 45
at Microsoft.Azure.Functions.Worker.OutputBindings.OutputBindingsMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a\_work\1\s\src\DotNetWorker.Core\OutputBindings\OutputBindingsMiddleware.cs:line 16
at Microsoft.Azure.Functions.Worker.Handlers.InvocationHandler.InvokeAsync(InvocationRequest request, WorkerOptions workerOptions) in D:\a\_work\1\s\src\DotNetWorker.Grpc\Handlers\InvocationHandler.cs:line 84
Stack: at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Microsoft.Azure.Functions.Worker.Invocation.DefaultFunctionInvoker`2.<>c.<InvokeAsync>b__6_0(Task`1 t) in D:\a\_work\1\s\src\DotNetWorker.Core\Invocation\DefaultFunctionInvoker.cs:line 32
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.Tasks.Task.<>c.<.cctor>b__273_0(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at Microsoft.Azure.Functions.Worker.Invocation.DefaultFunctionExecutor.ExecuteAsync(FunctionContext context) in D:\a\_work\1\s\src\DotNetWorker.Core\Invocation\DefaultFunctionExecutor.cs:line 45
at Microsoft.Azure.Functions.Worker.OutputBindings.OutputBindingsMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a\_work\1\s\src\DotNetWorker.Core\OutputBindings\OutputBindingsMiddleware.cs:line 16
at Microsoft.Azure.Functions.Worker.Handlers.InvocationHandler.InvokeAsync(InvocationRequest request, WorkerOptions workerOptions) in D:\a\_work\1\s\src\DotNetWorker.Grpc\Handlers\InvocationHandler.cs:line 84
Code snippet:
string logMessage = string.Empty;
// Get your public key
var strongGridClient = new StrongGrid.Client(_emailSettings.SendGridKey);
var publicKey = await strongGridClient.WebhookSettings.GetSignedEventsPublicKeyAsync().ConfigureAwait(false);
// Get the signature and the timestamp from the request headers
// SIGNATURE_HEADER_NAME is a convenient constant provided so you don't have to remember the name of the header
req.Headers.TryGetValues(WebhookParser.SIGNATURE_HEADER_NAME, out IEnumerable<string> signatures);
var signature = signatures?.FirstOrDefault();
// TIMESTAMP_HEADER_NAME is a convenient constant provided so you don't have to remember the name of the header
req.Headers.TryGetValues(WebhookParser.TIMESTAMP_HEADER_NAME, out IEnumerable<string> timestamps);
var timestamp = timestamps?.FirstOrDefault();
// Parse the events. The signature will be automatically validated and a security exception thrown if unable to validate
try
{
var parser = new WebhookParser();
var events = await parser.ParseSignedEventsWebhookAsync(req.Body, publicKey, signature, timestamp).ConfigureAwait(false);
// ... do something with the events...
foreach(var e in events.OrderBy(r => r.Timestamp).ToArray())
{
// My code
}
}
The text was updated successfully, but these errors were encountered:
HTTP errors in the 500 range indicate that the server can't complete the request because it encountered a problem. More specifically, 503 Service Unavailable error means that a website's server is not available right now. Most of the time, it occurs because the server is too busy or maintenance is being performed on it.
So, I encourage you to contact SendGrid directly to report this problem to them but keep us in the loop, let us know how they resolve it.
My key was generated couple of years ago. SendGrid said permission may not be correctly set for webhook and asked to regenerate the key and try. I'll update if the issue persists. Thanks for your help!!
I'm using StrongGrid 0.98.0. I get 503 error on calling WebhookSettings.GetSignedEventsPublicKeyAsync() in production environment. But it works fine in test environment. On looking at the settings in SendGrid console both environments are setup exactly the same. Any thoughts on what could be the issue?
Code snippet:
The text was updated successfully, but these errors were encountered: