I'm trying to use aws sdk to test goaws but my following program just hangs forever. Can anyone explain what I'm doing wrong here?
var AWS = require('aws-sdk');
var endpoint = new AWS.Endpoint('http://localhost:4100')
AWS.config.update({region: 'us-east-1'}, {endpoint});
// Create an SQS service object
var sqs = new AWS.SQS({apiVersion: '2012-11-05'});
var params = {
DelaySeconds: 10,
MessageAttributes: {
"Name": {
DataType: "String",
StringValue: "AAAA"
},
"SurName": {
DataType: "String",
StringValue: "BBBB"
}
},
MessageBody: "whats up",
QueueUrl: "http://us-east-1.goaws.com:4100/100010001000/local-queue1"
};
sqs.sendMessage(params, function(err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data.MessageId);
}
});
The sqs queue URL I tried testing with AWS cli and it does work. So there is something wrong in program which I don't understand.
aws sqs send-message --region us-east-1 --endpoint-url http://localhost:4100 --queue-url http://us-east-1.goaws.com:4100/100010001000/local-queue1 --message-body "Hello from Amazon SQS."
{
"MD5OfMessageBody": "c5dba0dd8f89fe763f66cbddb9c37cb7",
"MD5OfMessageAttributes": "",
"MessageId": "f5a8ce0d-983f-4fb5-b517-153d2c56c08b",
"SequenceNumber": ""
}
I don't see how your config
update will work. First, I don't think endpoint is an attribute on the global Config object. Also, it isn't set as an attribute in the dictionary, which should both the in the object that is the first argument. Next, I think you QueueUrl
should be http://localhost:4100/100010001000/local-queue1. I believe that endpoint
should be configured in the constructor for the SQS resource.
Here is some updated code that I have not tested, but I think will work.
var AWS = require('aws-sdk');
var endpoint = new AWS.Endpoint('http://localhost:4100')
AWS.config.update({region: 'us-east-1'});
// Create an SQS service object
var sqs = new AWS.SQS({
apiVersion: '2012-11-05',
endpoint: endpoint
});
var params = {
DelaySeconds: 10,
MessageAttributes: {
"Name": {
DataType: "String",
StringValue: "AAAA"
},
"SurName": {
DataType: "String",
StringValue: "BBBB"
}
},
MessageBody: "whats up",
QueueUrl: "http://localhost:4100/100010001000/local-queue1"
};
sqs.sendMessage(params, function(err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data.MessageId);
}
});
In addition, I think the logs coming from goaws would be helpful.