错误如下所示:
{ RequestError: Error: connect ECONNREFUSED 127.0.0.1:8200
at new RequestError (C:\Users\anand\quFlipApi\node_modules\request-promise\lib\errors.js:11:15)
at Request.RP$callback [as _callback] (C:\Users\anand\quFlipApi\node_modules\request-promise\lib\rp.js:60:32)
at self.callback (C:\Users\anand\quFlipApi\node_modules\request\request.js:188:22)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at Request.onRequestError (C:\Users\anand\quFlipApi\node_modules\request\request.js:884:8)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
at Socket.socketErrorListener (_http_client.js:310:9)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at emitErrorNT (net.js:1276:8)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)
name: 'RequestError',
message: 'Error: connect ECONNREFUSED 127.0.0.1:8200',
cause:
{ Error: connect ECONNREFUSED 127.0.0.1:8200
at Object.exports._errnoException (util.js:1026:11)
at exports._exceptionWithHostPort (util.js:1049:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1085:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 8200 },
error:
{ Error: connect ECONNREFUSED 127.0.0.1:8200
at Object.exports._errnoException (util.js:1026:11)
at exports._exceptionWithHostPort (util.js:1049:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1085:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 8200 },
options:
{ method: 'PUT',
path: '/sys/init',
json: { secret_shares: 1, secret_threshold: 1 },
headers: { 'X-Vault-Token': undefined },
uri: 'http://127.0.0.1:8200/v1/sys/init',
simple: false,
resolveWithFullResponse: true,
callback: undefined,
transform: undefined },
response: undefined }
Connection with database succeeded.
代码如下所示: app.js
var options = {
apiVersion: 'v1', // default
endpoint: 'http://127.0.0.1:8200' // default
};
// get new instance of the client
var vault = require("node-vault")(options);
// init vault server
vault.init({ secret_shares: 1, secret_threshold: 1 })
.then((result) => {
var keys = result.keys;
// set token for all following requests
vault.token = result.root_token;
// unseal vault server
return vault.unseal({ secret_shares: 1, key: keys[0] })
})
.catch(console.error);
我已经删除了clienttoken字段以避免任何复杂性,但它仍然给我错误。在上面的代码中我应该输入/删除任何其他字段以使其工作吗?