Вопрос

I have an app with two workers (Web and Background) on AppHarbor that connect to a MySql database hosted on Amazon's RDS.

I keep getting "Unable to connect to any of the specified MySQL hosts." exception.

The RDS instance in the US-East region and I have added the following AppHarbor CIDR to the security group.

  • 50.17.211.192/28
  • 54.235.159.192/27

I have added my own CIDR to the security group and I connect to the instance just fine. However when the app is running on AppHarbor it fails.

My connection string (censored) is:

Server=myinstanceXXXX.cykjvptrw5xs.us-east-1.rds.amazonaws.com;Database=MyDatabase;UID=XXXXXX;PWD=XXXXX;

I have tried including the port 3306 on the server endpoint but it made no difference.

Am I missing something on getting the two to play nice with one another?

Это было полезно?

Решение

By default AppHarbor use Amazon's internal DNS service for resolving hostnames. Because of that Amazon RDS instances in the same region as AppHarbor will resolve the private IP addresses rather than the public ones listed in the knowledge base article, so setting up rules based on the public IPs will not work most of the time.

In case Amazon's DNS service becomes unavailable we'll fail over to an external DNS service. This means you'll still have to configure the external IPs for the highest availability as an external DNS service will resolve the public IPs. This way you can ensure that your application is resilient towards DNS failures.

You can set up security group based access rules for your RDS security group. We've updated this knowledge base article with a section specifically for Amazon RDS where you can find the information necessary to set this up.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top