2

我正在尝试对使用 Node.js/Express 运行的 Amazon SimpleDB 进行非常简单的测试。这是我正在使用的代码(当然,AWS 密钥/秘密已消毒):

var express = require('express');
var simpledb = require('simpledb');

var app = express.createServer();
var sdb = new simpledb.SimpleDB(
        {keyed:'MYKEY', secret:'MYSECRET'}, simpledb.debuglogger);

app.get('/', function(req, res) {
        console.log("about to list domains...");
        sdb.listDomains(function(error, result, meta) {
                console.log("listing domains, I think?");
        });
});

app.listen(8888);

这是我得到的错误:

DEBUG: simpledb:  2012-04-06T01:34:24.856Z create {"keyid":"MYKEY","secret":"MYSECRET","secure":false,"consistent":true,"test":false,"maxtry":null,"expbase":null,"delaymin":null,"delayscale":null,"randomdelay":null} {"secure":false,"host":"sdb.amazonaws.com","path":"/","version":"2009-04-15","port":80}
about to list domains...
DEBUG: simpledb:  2012-04-06T01:34:29.253Z request 1333676069253 ListDomains {}
DEBUG: simpledb:  2012-04-06T01:34:29.387Z handle 1333676069253 ListDomains {"Action":"ListDomains","Version":"2009-04-15","SignatureMethod":"HmacSHA256","SignatureVersion":"2","Timestamp":"2012-04-06T01:34:29.253Z","AWSAccessKeyId":"MYKEY","Signature":"AWSSIGNATURE"} 1 false null

/home/rob/node_modules/simpledb/lib/simpledb.js:136
    if( res.Errors ) {
           ^
TypeError: Cannot read property 'Errors' of null
    at [object Object].handle (/home/rob/node_modules/simpledb/lib/simpledb.js:136:12)
    at /home/rob/node_modules/simpledb/lib/simpledb.js:188:18
    at Parser.<anonymous> (/home/rob/node_modules/simpledb/node_modules/aws-lib/lib/aws.js:81:13)
    at Parser.emit (events.js:67:17)
    at Object.onclosetag (/home/rob/node_modules/simpledb/node_modules/aws-lib/node_modules/xml2js/lib/xml2js.js:120:24)
    at emit (/home/rob/node_modules/simpledb/node_modules/aws-lib/node_modules/sax/lib/sax.js:148:32)
    at emitNode (/home/rob/node_modules/simpledb/node_modules/aws-lib/node_modules/sax/lib/sax.js:152:3)
    at closeTag (/home/rob/node_modules/simpledb/node_modules/aws-lib/node_modules/sax/lib/sax.js:226:5)
    at Object.write (/home/rob/node_modules/simpledb/node_modules/aws-lib/node_modules/sax/lib/sax.js:567:29)
    at Parser.<anonymous> (/home/rob/node_modules/simpledb/node_modules/aws-lib/node_modules/xml2js/lib/xml2js.js:145:29)

我对 Node.js、simpledb 模块和 SimpleDB 本身还是很陌生,但这对我来说似乎是 simpledb 模块中的一个错误。否则我无法弄清楚我做错了什么 - 我相信我的密钥/秘密是有效的(因为我已经分别和一起测试了无效的设置,并且我从亚马逊返回了实际错误,表明密钥/秘密无效)。

不过,这个错误让我很困惑。有任何想法吗?

4

2 回答 2

1

这原来是 simpledb 节点模块中的依赖问题:

嗨 - 这似乎是由最新版本的依赖库引起的 - 我已经重建并发布了一个新版本 0.0.8 - 请让我知道这是否有效 - 谢谢!

来源。它已经被修复了。

于 2012-04-09T15:55:16.543 回答
0

仅供参考 - 自从您发布原始帖子以来,AWS 已经发布了他们的 Node.js 官方开发工具包。 http://docs.aws.amazon.com/nodejs/latest/dg/nodejs-dg-examples.html

var AWS = require('aws-sdk');
AWS.config.update({region: 'us-east-1'});

var db = new AWS.SimpleDB();
db.client.listDomains(function(error, data) {
  if (error) {
    console.log(error);
  } else {
    console.log(data);
  }
});
于 2013-02-27T02:05:59.593 回答