0

I am using Neo4j database as graphenedb on Heroku connecting using Ember.js framework. The application is being run locally through Node.js (Not being run through Heroku server).

On a call to driver.session(); I receive this error:

WebSocket connection to 'ws://hobby-blablabla.dbs.graphenedb.com:24786/' failed: Error during WebSocket handshake: net::ERR_CONNECTION_RESET

I import driver using ember-browserify:

import Neo4j from 'npm:neo4j-driver';

I call the code:

var neo4j = Neo4j.v1;

var driver = neo4j.driver(graphenedbURL, neo4j.auth.basic(graphenedbUser, graphenedbPass));
var session = driver.session(); // error it thrown here

I retrieved the connection infos using Terminal commands with Heroku CLI like: heroku config:get GRAPHENEDB_BOLT_URL

Chances are that Heroku doesn't actually allow me to connect to the database from my local machine. But it would be really nice to work around this issue and be able to connect. Thank you for help.

Ragnar
  • 4,292
  • 4
  • 31
  • 41
  • I think you need to do some CROSS settings – XY L Feb 27 '17 at 02:39
  • Where would I go to fix it? contentSecurityPolicy in package.json does not seem to help unless I am using it wrong. – Ragnar Feb 27 '17 at 05:02
  • I no not sure where you should put your config using Node. However, when I using Rails there is a way to whitelist cross domain requests – XY L Feb 27 '17 at 05:05

2 Answers2

1

I'm Judit from GrapheneDB. If I understood you well, you're loading the Neo4j javascript driver in your Ember.js application and the driver is trying to connect to GrapheneDB database via WebSocket. Unfortunately this is something we don't support.

We always recommend to add to your stack a backend, that deals with the connection to GrapheneDB, and avoid doing it from the browser and prevent exposing your credentials to anybody using your app. You can build a Node.js server and manage the driver connections there using the same driver you are using now (npm install neo4j-driver).

BTW, you should be able to connect to your database from your local machine using the values of your Heroku environment variables. You can easily check by running:

 GDB_URL=`heroku config:get GRAPHENEDB_URL`
 curl -v $GDB_URL
  • Hi Judit, thank you for the answer. I am using bolt protocol and the WebSocket seems to be called internally by the neo4j-driver: bolt://hobby-herokuserver.dbs.graphenedb.com:24786 Locally the "ember server" command should be starting http://localhost:4200/. On the other hand using ember it still could be the browser who makes the final call. I will try to test that.Connecting curl seems to work. – Ragnar Feb 27 '17 at 18:49
  • So I setup separate node.js server with heroku and I can connect with GrapheneDB from both the remote server and heroku local. Looking more into the neo4j-driver I can see there is mentioned directly support of connecting through web browser though. Does it mean that Web Sockets are supported with Neo4j but not with GrapheneDB? (Just curious) – Ragnar Mar 01 '17 at 16:53
  • Nice to read that you were able to do it work. About your question, it's something our service doesn't support. – Judit Sarmiento Mar 15 '17 at 15:17
0

I believe you need to set CROSS setting. Not sure how to do so in Node, but following is what I did to set my Rails app,

Rails.application.config.middleware.insert_before 0, Rack::Cors do
  allow do
    origins '*'
    resource '*', headers: :any, methods: [
      :get, :post, :put, :patch, :delete, :options, :head
    ]
  end
end
XY L
  • 25,431
  • 14
  • 84
  • 143