简体   繁体   English

发送消息时的 AWS SQS“ECONNREFUSED”

[英]AWS SQS "ECONNREFUSED" when sending message

Trying to send Message to AWS SQS from nodejs.尝试从 nodejs 向 AWS SQS 发送消息。 I keep getting this specific error我不断收到此特定错误

{ Error: connect ECONNREFUSED 127.0.0.1:443
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1161:14)
  message: 'connect ECONNREFUSED 127.0.0.1:443',
  errno: 'ECONNREFUSED',
  code: 'NetworkingError',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 443,
  region: 'us-east-1',
  hostname: '',
  retryable: true,
  time: 2018-07-16T11:26:04.672Z }

I have set my credentials in my App, Given full access to my user for AWSSQSService.我已经在我的应用程序中设置了我的凭证,给予我的用户对 AWSSQSService 的完全访问权限。 I can get all the details about the queue itself, queue names, etc. I just cannot send a message to the queue.我可以获得有关队列本身、队列名称等的所有详细信息。我只是无法向队列发送消息。 My code below to send it我下面的代码发送它

{

    let AWS = require('aws-sdk');
    AWS.config.update({region: constants.AWS.AWS_REGION});
    let sqs = new AWS.SQS({apiVersion: '2012-11-05'});
    let SQSQueueUrl = ' https://sqs.us-east-1.amazonaws.com/*queueName*';
    let params = {
        MessageBody: 'demo', /* required */
        QueueUrl: SQSQueueUrl, /* required */
    };

    sqs.sendMessage(params, function(err, data) {
        if(err) 
            console.log(err);
        else 
            console.log(data);
    });

}

So, I came across the same error, remove the space at the start of your SQSQueueUrl, it solves the error.所以,我遇到了同样的错误,删除 SQSQueueUrl 开头的空格,它解决了错误。 so go with let SQSQueueUrl = ' https://sqs.us-east-1.amazonaws.com/ queueName ';所以使用let SQSQueueUrl = ' https://sqs.us-east-1.amazonaws.com/ queueName ';

That comes up when you don't configure access key and secret;当您不配置访问密钥和秘密时,就会出现这种情况; you can specify it either on line 2 with the config or via environment您可以使用配置或通过环境在第 2 行指定它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM