Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Lambda有时无法发布到SNS主题_Node.js_Aws Lambda_Amazon Sns - Fatal编程技术网

Node.js Lambda有时无法发布到SNS主题

Node.js Lambda有时无法发布到SNS主题,node.js,aws-lambda,amazon-sns,Node.js,Aws Lambda,Amazon Sns,我的AWS Lambda未能不时向AWS SNS主题发布消息 2020-03-09T08:02:42.520Z Could not publish on sns with error: NetworkingError: write EPROTO 2020-03-09T08:02:42.789Z Could not publish on sns with error: NetworkingError: Client network socket disconnected before secure

我的AWS Lambda未能不时向AWS SNS主题发布消息

2020-03-09T08:02:42.520Z Could not publish on sns with error: NetworkingError: write EPROTO
2020-03-09T08:02:42.789Z Could not publish on sns with error: NetworkingError: Client network socket disconnected before secure TLS connection was established
2020-03-09T08:04:14.797Z Could not publish on sns with error: NetworkingError: connect EPIPE 54.239.55.119:443
我正在
节点v12.13.0
上使用
aws sdk:2.632.0
。这些问题似乎是分块出现的(比如连续10个问题,然后一个小时内没有一个问题)

代码本身并不十分复杂:

const AWS = require('aws-sdk')
const executionRegion = process.env.AWS_REGION

const sns = new AWS.SNS({
  region: executionRegion
})

async function publishMessage(message, topic) {
  const snsMessage = {
    Message: JSON.stringify(message),
    TopicArn: topic
  }
  try {
    winston.info(`publish sns message ${JSON.stringify(snsMessage)}`);
    return await sns.publish(snsMessage).promise()
  } catch (err) {
    winston.error(`Could not publish message on sns :${err}`)
    return null
  }
}

你知道我能找出什么问题吗?

你能分享你的完整代码吗?比如如何使用aws sdk和创建sns实例?当然可以。我刚刚在问题中添加了代码。这里看起来没有任何错误。在一篇博文中,它读到了类似的问题。他们说,在创建sns instanceIt的过程中尝试添加
{httpOptions:{agent:new https.agent({secureProtocol:'TLSv1_method',ciphers:'ALL“}}}
在95%的情况下都能工作,这就是为什么很难解决这个问题的原因。谢谢你的提示,我会尝试一下。刚刚选中-添加
httpOptions
没有帮助。你能分享你的完整代码吗?比如如何使用aws sdk和创建sns实例?当然可以。我刚刚在问题中添加了代码。这里看起来没有任何错误。在一篇博文中,它读到了类似的问题。他们说,在创建sns instanceIt的过程中尝试添加
{httpOptions:{agent:new https.agent({secureProtocol:'TLSv1_method',ciphers:'ALL“}}}
在95%的情况下都能工作,这就是为什么很难解决这个问题的原因。谢谢你的提示,我会尝试一下。只是选中-添加
httpOptions
没有帮助