Search code examples
amazon-web-servicesaws-sdkamazon-sesaws-sdk-net

AWS .Net Core SDK Simple Email Service Suppression List Not Working


I am trying to retrieve the SES account-level suppression list using AWS SDK in .Net Core:

Below is my code:

public class SimpleEmailServiceUtility : ISimpleEmailServiceUtility
{
    private readonly IAmazonSimpleEmailServiceV2 _client;

    public SimpleEmailServiceUtility(IAmazonSimpleEmailServiceV2 client)
    {
        _client = client;
    }

    public async Task<ListSuppressedDestinationsResponse> GetSuppressionList()
    {
        ListSuppressedDestinationsRequest request = new ListSuppressedDestinationsRequest();
        request.PageSize = 10;

        ListSuppressedDestinationsResponse response = new ListSuppressedDestinationsResponse();
        
        try
        {
            response = await _client.ListSuppressedDestinationsAsync(request);
        }
        catch (Exception ex)
        {
            Console.WriteLine("ListSuppressedDestinationsAsync failed with exception: " + ex.Message);
        }

        return response;
    }
}

But it doesn't seem to be working. The request takes too long and then returns empty response or below error if I remove try/catch:

An unhandled exception occurred while processing the request.
TaskCanceledException: A task was canceled.
System.Threading.Tasks.TaskCompletionSourceWithCancellation<T>.WaitWithCancellationAsync(CancellationToken cancellationToken)

TimeoutException: A task was canceled.
Amazon.Runtime.HttpWebRequestMessage.GetResponseAsync(CancellationToken cancellationToken)

Can anyone please guide if I am missing something?

Thank you!


Solution

  • Finally found the issue, I was using awsConfig.DefaultClientConfig.UseHttp = true;' in startup` which was causing the issue. Removing it fixed the issue and everything seems to be working fine now.