5

我正在使用这个NPM 插件来处理在我的 Node 应用程序中创建本地 DynamoDB 本地服务器。出于某种原因,有时它会给我以下错误。无法弄清楚为什么,但在特定测试部分运行测试时似乎总是会发生这种情况。

绝对不会每次都发生。也许50%左右。很奇怪。

我已阅读该错误意味着启动 DynamoDB 本地服务器失败。但我不知道为什么,因为它没有提供更多细节。

DynamoDB Local failed to start with code 1
{ Error: connect ECONNREFUSED 127.0.0.1:8000
    at Object.exports._errnoException (util.js:1012:11)
    at exports._exceptionWithHostPort (util.js:1035:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1080:14)
  message: 'connect ECONNREFUSED 127.0.0.1:8000',
  code: 'NetworkingError',
  errno: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 8000,
  region: 'us-west-2',
  hostname: 'localhost',
  retryable: true,
  time: 2016-09-13T03:26:05.804Z }

哦,这是我创建服务器的代码。

    dynamodbLocal.start({port : dbport, /* Port to listen on. Default: 8000 */
         cors : '*', /* Enable CORS support (cross-origin resource sharing) for JavaScript. You must provide a comma-separated "allow" list of specific domains. The default setting for cors is an asterisk (*), which allows public access. */
         inMemory : false, /* DynamoDB; will run in memory, instead of using a database file. When you stop DynamoDB;, none of the data will be saved. Note that you cannot specify both dbPath and inMemory at once. */
         dbPath : __dirname + '/dynamodb/', /* The directory where DynamoDB will write its database file. If you do not specify this option, the file will be written to the current directory. Note that you cannot specify both dbPath and inMemory at once. For the path, current working directory is <projectroot>/node_modules/dynamodb-localhost/dynamob. For example to create <projectroot>/node_modules/dynamodb-localhost/dynamob/<mypath> you should specify '<mypath>/' with a forwardslash at the end. */
         sharedDb : false, /* DynamoDB will use a single database file, instead of using separate files for each credential and region. If you specify sharedDb, all DynamoDB clients will interact with the same set of tables regardless of their region and credential configuration. */
         delayTransientStatuses : false, /* Causes DynamoDB to introduce delays for certain operations. DynamoDB can perform some tasks almost instantaneously, such as create/update/delete operations on tables and indexes; however, the actual DynamoDB service requires more time for these tasks. Setting this parameter helps DynamoDB simulate the behavior of the Amazon DynamoDB web service more closely. (Currently, this parameter introduces delays only for global secondary indexes that are in either CREATING or DELETING status.) */
         optimizeDbBeforeStartup : true /* Optimizes the underlying database tables before starting up DynamoDB on your computer. You must also specify -dbPath when you use this parameter. */
        });

有任何想法吗?

4

0 回答 0