通信链路失败,无法将 Spring Boot 应用程序连接到 AWS Aurora。

huangapple go评论105阅读模式
英文:

Communications link failure connecting spring boot app to aws aurora

问题

我正在尝试将我本地创建的 Spring Boot 应用程序连接到 AWS 无服务器 Aurora 数据库。

我已经添加了 Maven 依赖:

  1. <dependency>
  2. <groupId>mysql</groupId>
  3. <artifactId>mysql-connector-java</artifactId>
  4. <version>8.0.18</version>
  5. </dependency>

同时创建了一个 application.properties 文件:

  1. spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
  2. spring.jpa.show-sql=true
  3. spring.jpa.hibernate.ddl-auto=update
  4. spring.datasource.url=jdbc:mysql://myawsclusterlink:3306/mycluster
  5. spring.datasource.username=myusername
  6. spring.datasource.password=mypassword
  7. spring.datasource.hikari.minimum-idle=0
  8. spring.datasource.hikari.maximum-pool-size=10
  9. spring.datasource.hikari.connection-timeout=60000
  10. spring.datasource.hikari.max-lifetime=90000
  11. spring.datasource.hikari.idle-timeout=90000

我还为数据库创建了一个 VPC 入站规则组,以允许来自我的 IP 地址的流量。

我的问题是,当我运行应用程序时,我的连接始终失败,并显示错误消息:

  1. com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
  2. The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

我想知道问题出在哪里。我的 URL 是不正确的吗?我在 AWS 上没有启用某些内容吗?我的代码中是否有遗漏的部分?

另外,我实际上不知道如何测试并查看此情况下问题的根源。

英文:

I am trying to connect the spring boot application I have created locally to an aws serverless aurora database.

I have added the maven dependency:

  1. &lt;dependency&gt;
  2. &lt;groupId&gt;mysql&lt;/groupId&gt;
  3. &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
  4. &lt;version&gt;8.0.18&lt;/version&gt;
  5. &lt;/dependency&gt;

As well as created an application.properties file:

  1. spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
  2. spring.jpa.show-sql=true
  3. spring.jpa.hibernate.ddl-auto=update
  4. spring.datasource.url=jdbc:mysql://myawsclusterlink:3306/mycluster
  5. spring.datasource.username=myusername
  6. spring.datasource.password=mypassword
  7. spring.datasource.hikari.minimum-idle=0
  8. spring.datasource.hikari.maximum-pool-size=10
  9. spring.datasource.hikari.connection-timeout=60000
  10. spring.datasource.hikari.max-lifetime=90000
  11. spring.datasource.hikari.idle-timeout=90000

I have also created a VPC inbounds group for the db to allow incoming traffic from my IP address.

My Issue is that that when I run the app, my connection keeps failing with an error message:

  1. com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
  2. The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

I would like to know where is the problem. Is my url wrong? Have I not enabled something on aws? Is there something missing in my code?

Also, I don't really know how to test and see where the problem is coming from in this case.

答案1

得分: -1

从无服务器切换到预置的Aurora并启用公共访问解决了这个问题。

英文:

Changing from serverless to provisioned aurora and enabling public access solved the issue

huangapple
  • 本文由 发表于 2020年10月1日 23:31:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/64158581.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定