Quantcast
Channel: Active questions tagged amazon-ec2 - Stack Overflow
Viewing all articles
Browse latest Browse all 29422

How to access Neo4j on EC2 from Node

$
0
0

I set up a Neo4j database on an EC2 instance. I attached a domain name and created a certificate so that I can access the browser version from https://my-domain-name:7473. From the browser, I can create nodes and modify the database.

Now I want to be able to modify this database from Node, but it's not working. This is what I have:

const neo4j = require('neo4j-driver');
const driver = neo4j.driver('bolt://my-domain-name', neo4j.auth.basic('neo4j', 'instance-id-password'));
const session = driver.session();

session
    .run(`MATCH (n:User) RETURN n`)
    .then(function (result) {
        result.records.forEach(function (record) {
            console.log(record._fields[0].properties);
        });
    })
    .catch(function (err) {
        console.log('ERROR WITH NEO4J CALL');
        console.log(err);
    });

The error I get is

ERROR WITH NEO4J CALL
{ Neo4jError: Connection was closed by server

    at captureStacktrace (C:\Users\admin\Documents\TestingAWSServerlessExtension\test-node-neo4j\node_modules\neo4j-driver\lib\result.js:263:15)
    at new Result (C:\Users\admin\Documents\TestingAWSServerlessExtension\test-node-neo4j\node_modules\neo4j-driver\lib\result.js:68:19)
    at Session._run (C:\Users\admin\Documents\TestingAWSServerlessExtension\test-node-neo4j\node_modules\neo4j-driver\lib\session.js:172:14)
    at Session.run (C:\Users\admin\Documents\TestingAWSServerlessExtension\test-node-neo4j\node_modules\neo4j-driver\lib\session.js:135:19)
    at Object.<anonymous> (C:\Users\admin\Documents\TestingAWSServerlessExtension\test-node-neo4j\index.js:7:6)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3) code: 'ServiceUnavailable', name: 'Neo4jError' }

I know the cypher query works because when I run this same code replacing my-domain-name with localhost, I get the expected output. So I can't access my Neo4j database unless I am hosting it locally. Any ideas?


Viewing all articles
Browse latest Browse all 29422

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>