简体   繁体   中英

Neo4j/graphenedb on Heroku Node.js/Ember.js WebSocket ERR_CONNECTION_RESET issue

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM