在Amazon Ec2服务器上丢失数据库连接

时间:2023-01-26 12:42:04

For the last few months I am facing an issue, I deployed my application on amazon ec2 server but at least 10 to 30 times a day I get these errors.

在过去的几个月里我遇到了一个问题,我在amazon ec2服务器上部署了我的应用程序,但每天至少有10到30次我得到这些错误。

1) Error: connect ETIMEDOUT
    at errnoException (net.js:904:11)
    at Object.afterConnect [as oncomplete] (net.js:895:19)

2) Error: getaddrinfo ENOTFOUND
     at errnoException (dns.js:37:11)
     at Object.onanswer [as oncomplete] (dns.js:124:16)
     --------------------
    at Handshake.Sequence                                            (/var/app/current/node_modules/mysql/lib/protocol/sequences/Sequence.js:15:20)
at new Handshake (/var/app/current/node_modules/mysql/lib/protocol/sequences/Handshake.js:9:12)
at Protocol.handshake (/var/app/current/node_modules/mysql/lib/protocol/Protocol.js:42:50)
at Connection.connect (/var/app/current/node_modules/mysql/lib/Connection.js:72:18)
at module.exports.connect (/var/app/current/node_modules/sequelize/lib/dialects/mysql/connector-manager.js:276:16)
at Object.pool.Pooling.Pool.create (/var/app/current/node_modules/sequelize/lib/dialects/mysql/connector-manager.js:125:19)
at createResource (/var/app/current/node_modules/sequelize/node_modules/generic-pool/lib/generic-pool.js:258:13)
at dispense (/var/app/current/node_modules/sequelize/node_modules/generic-pool/lib/generic-pool.js:250:9)
at Object.me.acquire (/var/app/current/node_modules/sequelize/node_modules/generic-pool/lib/generic-pool.js:316:5)
at module.exports.enqueue (/var/app/current/node_modules/sequelize/lib/dialects/mysql/connector-manager.js:320:19)

3) TypeError: Uncaught, unspecified "error" event.
at TypeError (<anonymous>)
at EventEmitter.emit (events.js:74:15)
at Handshake._callback (/var/app/current/node_modules/sequelize/lib/dialects/mysql/connector-manager.js:286:19)
at Handshake.Sequence.end (/var/app/current/node_modules/mysql/lib/protocol/sequences/Sequence.js:75:24)
at Protocol.handleNetworkError (/var/app/current/node_modules/mysql/lib/protocol/Protocol.js:238:14)
at Connection._handleNetworkError (/var/app/current/node_modules/mysql/lib/Connection.js:155:18)
at Socket.EventEmitter.emit (events.js:117:20)
at net.js:830:16
at process._tickDomainCallback (node.js:459:13)

Any idea how to fix these issues ?

知道如何解决这些问题吗?

Before posting here I posted similar question on github as well and I got unsatisfactory answer that this is an amazon issue and many of the people are facing it.

在发布之前我在github上发布了类似的问题,我得到了令人不满意的答案,这是一个亚马逊问题,很多人都面临着这个问题。

So guys any suggestion or solution regarding this issue ?

那么有关于这个问题的任何建议或解决方案吗?

2 个解决方案

#1


2  

Your error number 2 is where I was stuck few days ago, I found a solution by clouddueling , here https://github.com/aws/aws-sdk-js/issues/55

您的错误号码2是我几天前卡住的地方,我通过clouddueling找到了解决方案,在这里https://github.com/aws/aws-sdk-js/issues/55

hope this helps, if you are not facing an amazon issue.

希望这有帮助,如果你没有面对亚马逊问题。

#2


0  

This could in fact be a DNS issue depending on your set-up. Based on your question I am presuming that the MySQL database is installed on that same host as your application, if not, the same solution would apply.

实际上这可能是DNS问题,具体取决于您的设置。基于您的问题,我假设MySQL数据库安装在与您的应用程序相同的主机上,否则,将应用相同的解决方案。

Edit your hosts file and hardcode your MySQL hostname and IP address and check to see if that resolved your problem. If it does then you need to check your nameservers (use Google's 8.8.8.8 and 8.8.4.4), and make sure that you've set-up your DNS correctly.

编辑您的主机文件并硬编码您的MySQL主机名和IP地址,并检查是否解决了您的问题。如果是,那么您需要检查您的名称服务器(使用Google的8.8.8.8和8.8.4.4),并确保您正确设置了DNS。

Never hardcode anything, only use this method to deduce if DNS is in fact the cause.

永远不要硬编码任何东西,只使用这种方法来推断DNS是否实际上是原因。

#1


2  

Your error number 2 is where I was stuck few days ago, I found a solution by clouddueling , here https://github.com/aws/aws-sdk-js/issues/55

您的错误号码2是我几天前卡住的地方,我通过clouddueling找到了解决方案,在这里https://github.com/aws/aws-sdk-js/issues/55

hope this helps, if you are not facing an amazon issue.

希望这有帮助,如果你没有面对亚马逊问题。

#2


0  

This could in fact be a DNS issue depending on your set-up. Based on your question I am presuming that the MySQL database is installed on that same host as your application, if not, the same solution would apply.

实际上这可能是DNS问题,具体取决于您的设置。基于您的问题,我假设MySQL数据库安装在与您的应用程序相同的主机上,否则,将应用相同的解决方案。

Edit your hosts file and hardcode your MySQL hostname and IP address and check to see if that resolved your problem. If it does then you need to check your nameservers (use Google's 8.8.8.8 and 8.8.4.4), and make sure that you've set-up your DNS correctly.

编辑您的主机文件并硬编码您的MySQL主机名和IP地址,并检查是否解决了您的问题。如果是,那么您需要检查您的名称服务器(使用Google的8.8.8.8和8.8.4.4),并确保您正确设置了DNS。

Never hardcode anything, only use this method to deduce if DNS is in fact the cause.

永远不要硬编码任何东西,只使用这种方法来推断DNS是否实际上是原因。