【问题标题】:Getting getaddrinfo ENOTFOUND when trying to connect to my AWS Neptune with node.js and gremlin尝试使用 node.js 和 gremlin 连接到我的 AWS Neptune 时获取 getaddrinfo ENOTFOUND
【发布时间】:2021-12-30 15:37:54
【问题描述】:

我正在尝试从 API GW 连接到我的 Amazon Neptune 实例。我正在使用 Node.js 和 Lambda

我的 YML 是这样的

  NeptuneDBCluster:
    Type: "AWS::Neptune::DBCluster"

Outputs:
  NeptuneEndpointAddress:
    Description: Neptune DB endpoint address
    Value: !GetAtt NeptuneDBCluster.Endpoint
    Export:
      Name: !Sub ${env:STAGE}-neptune-endpoint-address

我的代码是这样的

const gremlin = require('gremlin');
const {
    NEPTUNE_ENDPOINT
} = process.env;
const { cardinality: { single } } = gremlin.process;
const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;
const Graph = gremlin.structure.Graph;

async function createUserNode(event, context, callback) {
    const url = 'wss://" + NEPTUNE_ENDPOINT + ":8182/gremlin';
    const dc = new DriverRemoteConnection(url);

    const parsedBody = JSON.parse(event.body);


    try {
        const graph = new Graph();
        const g = graph.traversal().withRemote(dc);

        const vertex = await g.addV(parsedBody.type)
            .property(single, 'name', parsedBody.name)
            .property(single, 'username', parsedBody.username)
            .property('age', parsedBody.age)
            .property('purpose', parsedBody.purpose)
            .next();

        if (vertex.value) {
            return callback(null, {
                statusCode: 200,
                body: vertex.value
            });
        }

    } catch (error) {
        console.error(error);
    }

};

我不断从 Cloudwatch 收到以下错误(我也尝试创建一个本地 js 文件,但它给出了相同的错误)

ERROR   Error: getaddrinfo ENOTFOUND my-url
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26) {
  errno: 'ENOTFOUND',
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'my-url'
}

我也尝试在没有从 process.env 中获取端点的情况下编写端点,但我仍然面临同样的问题。我错过了什么?

【问题讨论】:

    标签: node.js aws-lambda aws-api-gateway gremlin amazon-neptune


    【解决方案1】:

    对于第一次尝试海王星时和我一样困惑的人来说,好吧。您还需要创建一个数据库实例,我以为 Serverless Framework 会这样做,但现在我知道了。

    【讨论】:

      猜你喜欢
      • 2019-06-04
      • 2019-08-10
      • 2021-12-07
      • 2013-07-15
      • 1970-01-01
      • 1970-01-01
      • 2016-04-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多