Home > Article > Backend Development > Connect to AWS Neptune using Golang GremlinGo
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()) } }
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
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!