arnoldasgudas / Hangfire.MySqlStorage

MySql storage for Hangfire - fire-and-forget, delayed and recurring tasks runner
GNU Lesser General Public License v3.0
174 stars 114 forks source link

Access Denied with AWS Aurora MySql #88

Open dvinaybabu opened 2 years ago

dvinaybabu commented 2 years ago

We are on .Net Core 3.1 using the below Hangfire libraries to manage our recurring jobs. Hangfire.AspNetCore Version = 1.7.12 Hangfire.Core Version = 1.7.12 Hangfire.MySqlStorage Version = 2.0.0

We are still on EF Core 2.1.4 to overcome some issues with EF Core 3.1 and hence had to use the older compatible Hangfire libraries

We use AWS Aurora MySql database, and the application uses an IAM role to connect to the database. The password is not a fixed one, but generated using the Amazon RDS utility "RDSAuthTokenGenerator.GenerateAuthToken". This is valid for only 15 minutes.

The constructor in the Hangfire.MySqlStorage class only allows to either pass a connection string or a connection object, and using either of them we get Access Denied exceptions after 15 minutes

We tried to update the MySqlStorage object used by the background services using the "GlobalConfiguration.Configuration.UseStorage" call every 2 minutes to make sure the object always holds the updated connection string.

However, not all background services seem to be using the JobStorage.Current object, and they result in the Access denied exception once the password token is expired after 15 minutes

Any pointers on how we can overcome this issue and keep the connection string updated.