aws-samples / aws-samples/aws-netcoreapi-aurora-cdk

Unable to connect to Aurora MySql using .net core application deployed on Aws Ecs

Open
#4 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
12
Forks
3
PR merge metrics
No merged PRs in 30d

Description

I have an application in .net core 3.1 and I am using MySql with that. To connect to MySql I am using Pomelo.EntityFrameworkCore.MySql nuget.

My .net core application is deployed as a docker container on AWS ECS and I am using Aurora MySql RDS to store data. I have granted "Publicly accessible" access to the Aurora MySql and I can connect to the db using MySql workbench and also with my .net core application using localhost. But when I deploy the application and try to perform any db action then it starts giving throwing exception:

> An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure()' to the 'UseMySql' call.

Then I have added retry pattern like this:

```
services.AddDbContextPool(options =>
options.UseMySql(Configuration.GetConnectionString("DefaultConnection"), builder =>
{
builder.EnableRetryOnFailure(5, TimeSpan.FromSeconds(5), null);
}
);
```
and my connection string is something like this:

`"DefaultConnection": "Server=db-cluster-1-instance-1.cqb2fsjwx78p.us-east-2.rds.amazonaws.com;Database=dbName;User ID=admin;Password=password;port=3306"`
After adding retry pattern. I am getting this error:

> "Maximum number of retries (5) exceeded while executing database operations with 'MySqlRetryingExecutionStrategy'. See inner exception for the most recent failure."

So I suspect, it's something else. What am I doing wrong here? Or it might be something wrong in aws

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.