neo4j / neo4j-browser

Neo4j Browser is the general purpose user interface for working with Neo4j. Query, visualize, administrate and monitor the database.
https://neo4j.com
GNU General Public License v3.0
699 stars 351 forks source link

neo4j-browser cannot connect to server running in vagrant machine. #637

Closed rvalenciano closed 7 years ago

rvalenciano commented 7 years ago

Description

I installed neo4j in a Vagrant machine which I use to develop. The actual installation completes ok, and I managed to connect an express app using passport to the neo4j browser. This means I'm able to sign up users and login with them. However, I want to use neo4j browser and I'm not able to. According to the logs, when I try to stablish a connection with bolt, it fails with


2017-08-27 15:54:56.776+0000 ERROR [o.n.b.t.SocketTransportHandler] Fatal error occurred when handling a client connection: Could not initialize class org.neo4j.bolt.v1.packstream.utf8.SunMiscUTF8Encoder Could not initialize class org.neo4j.bolt.v1.packstream.utf8.SunMiscUTF8Encoder
java.lang.NoClassDefFoundError: Could not initialize class org.neo4j.bolt.v1.packstream.utf8.SunMiscUTF8Encoder

Screenshot from the browser:

screen shot 2017-08-27 at 10 09 20 am

Reproduce Steps

 N/A: WebSocket connection failure. Due to security constraints in your web browser, the reason for the failure is not available to this Neo4j Driver. Please use your browsers development console to determine the root cause of the failure. Common reasons include the database being unavailable, using the wrong connection URL or temporary network problems. If you have enabled encryption, ensure your browser is configured to trust the certificate Neo4j is configured to use. WebSocket `readyState` is: 3

2017-08-27 15:54:56.776+0000 ERROR [o.n.b.t.SocketTransportHandler] Fatal error occurred when handling a client connection: Could not initialize class org.neo4j.bolt.v1.packstream.utf8.SunMiscUTF8Encoder Could not initialize class org.neo4j.bolt.v1.packstream.utf8.SunMiscUTF8Encoder
java.lang.NoClassDefFoundError: Could not initialize class org.neo4j.bolt.v1.packstream.utf8.SunMiscUTF8Encoder

Expected Behavior

I should be able to connect to my vagrant neo4j using neo4j browser

Current Behavior

Doesn't connect to neo4j server.

Can you propose a solution?

Not sure about what to do or how to help.

Your Environment

software name version
OS Ubuntu 14 in a Vagrant machine running with a host MacOS Sierra
Web browser Chrome 60.0, Firefox 55.0.2
node.js 6.11.2
npm 3.10.10
yarn NA
Neo4j Browser 3.0.5
Neo4j 3.2.3

Additional Information

Please note, as I mention before, I'm able to connect my express app with neo4j and register/login users using passport, so the db is working ok.

How I installed neo4j in my ubuntu vagrant machine:

Below you can see my neo4j.sh script.

cd;
# Neo4j requires java
# sudo apt install default-jre default-jre-headless -y
# sudo update-alternatives -set java /usr/lib/jvm/java-8-openjdk-amd64/bin/java
# sudo update-alternatives -set javac /usr/lib/jvm/java-8-openjdk-amd64/bin/javac
sudo wget --no-check-certificate -O - https://debian.neo4j.org/neotechnology.gpg.key | apt-key add -
sudo add-apt-repository ppa:webupd8team/java -y
sudo apt-get update -y
echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections
sudo apt-get install oracle-java8-installer -y
sudo rm /var/cache/oracle-jdk8-installer/jdk-*
sudo apt-get install -f
sudo dpkg --configure -a
sudo su
echo 'deb http://debian.neo4j.org/repo stable/' >/etc/apt/sources.list.d/neo4j.list
exit
sudo apt-get update -y
sudo apt-get install neo4j -y
service neo4j status
# to accept connections from host
sudo echo "dbms.connectors.default_listen_address=0.0.0.0" >> /etc/neo4j/neo4j.conf
sudo echo "dbms.connector.bolt.address=0.0.0.0:7687" >> /etc/neo4j/neo4j.conf

sudo service neo4j restart
vagrant ssh -c 'curl localhost:7474'
vagrant ssh -c 'curl -H "Content-Type: application/json" -XPOST -d \'{"password":"XXXXX"}\' -u neo4j:neo4j http://localhost:7474/user/neo4j/password'
My vagrantfile

Here you can verify also I have mapped ports:


# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://vagrantcloud.com/search.
  config.vm.box = "ubuntu/trusty64"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # NOTE: This will enable public access to the opened port
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine and only allow access
  # via 127.0.0.1 to disable public access
  # install nodejs
  config.vm.provision "shell", path: "./scripts/nodejs.sh"
  config.vm.provision "shell", path: "./scripts/neo4j.sh"
  config.vm.provision "shell", path: "./scripts/utils.sh"
  config.vm.provision "file", source: "../.", destination: "~/"
  # neo4j
  config.vm.network "forwarded_port", guest: 7474, host: 7474
  config.vm.network "forwarded_port", guest: 7687, host: 7687
  # Express hearing
  config.vm.network "forwarded_port", guest: 3000, host: 3000

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network "private_network", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  config.vm.synced_folder "../../grid", "/home/vagrant/grid"
  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
    vb.memory = "2048"
  end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Enable provisioning with a shell script. Additional provisioners such as
  # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end

As you can see, I've applied many suggestions found in other questions like allowing to hear from all sources, I've also turned off IPTABLES and it's the same.

oskarhane commented 7 years ago

Thanks for the report @rvalenciano Could you check your web browsers JS Console for any error messages? You open it by pressing Command+Option+I (Mac) or Control+Shift+I (Windows, Linux).

rvalenciano commented 7 years ago

Hi @oskarhane , just this:

neo4j-web.min.js:18 WebSocket is already in CLOSING or CLOSED state.

Not very useful ... guess that's why the message of the neo4j log is like the one that gives the most important clue.

oskarhane commented 7 years ago

My experience and knowledge with Vagrant is very limited. Does Vagrant support forwarding of the websocket protocol?

andrewdalpino commented 7 years ago

I was having the same issue as @rvalenciano above on a server running Oracle Java9, switched to 8 and everything works fine now.

DavidKDeutsch commented 7 years ago

Thanks @andrewdalpino; I've been facing the same problem on a Windows 10 machine and that was the issue.

oskarhane commented 7 years ago

Closing this because it seems like it's resolved, feel free to open if it still exists.

suchetaswabhav commented 6 years ago

Please check . I get this error - https://community.neo4j.com/t/error-websocket-is-already-in-closing-or-closed-state/2564

OS - ubuntu : 16