当我尝试使用 npm 包 sendgrid/mail 发送电子邮件时,有时会弹出此错误消息。这在大多数情况下都有效。
{ Error: connect ETIMEDOUT 169.45.89.179:443 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1104:14) errno: 'ETIMEDOUT', code: 'ETIMEDOUT', syscall: 'connect',
address: '169.45.89.179', port: 443 } [bugsnag] Reported an unhandled rejection… Error: Error: connect ETIMEDOUT 169.45.89.179:443 at SendGrid.send.then.catch.e (/home/leoqiu/foodnome-api/build/src/utils/emailHelpers.js:143:11)
我的 Node 服务器使用以下代码发送它:
export const sendVerifyMail = (to: string, token: string) =>
SendGrid.send({
to,
from: { email: '..' },
subject: 'Verify you..',
dynamic_template_data: {
header: 'Verify your account',
text:
'Please use the button below to continue the process.',
c2a_link: `${serverAddress}/api/user-account/verify?token=${token}`,
c2a_button: 'Verify'
},
template_id: 'd-0f6411434fbc4896bf389e3945affd5d'
} as any)
.then(d => d)
.catch(e => {
console.log(e);
throw new Error(e);
});
最佳答案
我认为这不是您的代码或您网络一侧的问题,除非您同时遇到一般连接问题。
ip 169.45.89.179 解析为 sendgrid 的域,因此这可能是他们的问题,要仔细检查这一点,您可以设置对 8.8.8.8 的连续 ping 或运行其他一些网络监控设置以确保您的连接稳定。
如果您的连接不是问题,我会将其连同您准备共享的任何日志一起报告给他们,您的源 IP 和发生超时错误的时间可能对他们有用
关于node.js - sendgrid 使用 @sendgrid/mail 设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54861659/