Home > Backend Development > Golang > Connect to AWS Neptune using Golang GremlinGo

Connect to AWS Neptune using Golang GremlinGo

WBOY
Release: 2024-02-08 20:53:54
forward
748 people have browsed it

使用 Golang GremlinGo 连接到 AWS Neptune

Question content

I'm currently trying to establish a connection to aws neptune via go but it's not working. I am able to connect to aws itself, but when I try to connect to neptune db it says "Unable to establish successful connection: Call tcp 172.31.4.48:8182: i/o timeout". I'm using gremlingo module like this code

package main

import (
    "fmt"
    "net/http"

    "github.com/aws/aws-sdk-go/aws"
    "github.com/aws/aws-sdk-go/aws/credentials"
    "github.com/aws/aws-sdk-go/aws/session"
    "github.com/aws/aws-sdk-go/service/neptune"
    "github.com/gin-gonic/gin"

    gremlingo "github.com/apache/tinkerpop/gremlin-go/v3/driver"
)

func main() {

    sess, err := session.NewSession(&aws.Config{
        Region:      aws.String("us-east-id1"),
        Credentials: credentials.NewStaticCredentials("AWS-id key", "aws secret id key", ""),
    })

    if err != nil {
        fmt.Println("Couldn't create new session")
        return
    }

    neptune.New(sess)

    driverRemoteConnection, err := gremlingo.NewDriverRemoteConnection("wss://database-1-instance-1.asdasdasd.us-east-1.neptune.amazonaws.com:8182/gremlin",
        func(settings *gremlingo.DriverRemoteConnectionSettings) {
            settings.TraversalSource = "g"
        })

    if err != nil {
        fmt.Println(err)
        return
    }

    //Cleanup
    defer driverRemoteConnection.Close()

    //Creating graph traversal
    g := gremlingo.Traversal_().WithRemote(driverRemoteConnection)

    // Perform traversal
    results, err := g.V().Limit(2).ToList()
    if err != nil {
        fmt.Println(err)
        return
    }

    // print results
    for _, r := range results {
        fmt.Println(r.GetString())
    }
}
Copy after login

I'm not quite sure what the problem is, so I tried connecting to the cluster itself, but since it didn't work, I tried connecting to the writer. Thank you for your help.

Best Regards


Correct Answer


Amazon Neptune runs inside a VPC and does not expose public endpoints. Code designed to send queries must have access to the VPC. This could be as simple as code running on an EC2 instance in the same VPC, but there are many other ways to grant access to a VPC, such as load balancers, VPC peering, direct connections, and more. p>

A simple way to check if your code can access the database is to send an HTTP request to the /status API from the same origin point and see if it works.

The above is the detailed content of Connect to AWS Neptune using Golang GremlinGo. For more information, please follow other related articles on the PHP Chinese website!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template