0

如何让 RStudio 连接到 Neo4j 数据库?

问题:

当我尝试使用startGraph通过 RStudio 连接到 neo4j 数据库时,会显示以下错误:

错误: 服务器错误:(503)服务不可用

#load library
library(RNeo4j)

#connect to graphdb
graph = startGraph("http://localhost:7474/db/data/")

(禁用 dbm 身份验证 [dbms.security.auth_enabled=false])(还尝试启用身份验证(通过将 db 用户名和密码传递给 startGraph),但显示相同的错误)

graph = startGraph("http://localhost:7474/db/data", 
         username="xxxx", password="xxxx")

初始设置检查:

确认 Neo4j 安装和运行成功。

1.Database is started and running successfully via neo4j (3.0.1) console

2.Confirmed able to connect successfully via Chrome Browser

3.Confirmed able to create graph and conduct queries via Chrome Browser interface.

环境信息

    proxy is configured on system
    RNeo4j version 1.6.4
    RStudio V. 0.99.892
    R version 3.2.4 (2016-03-10)
    Platform: x86_64-w64-mingw32/x64 (64-bit)
    Running under: Windows 7 x64 (build 7601) Service Pack 1

额外细节

我对代理和 RStudio 创建和运行 Shiny Apps 或在系统上安装任何 R 包没有任何问题。

我执行了一个 netstat 来检查 localhost 端口上的连接,只有连接的应用程序是 Neo4j 和 Web 浏览器,而不是 RStudio。(一次打开这么多连接正常吗?)

d:\Windows\System32\drivers\etc>netstat -a -o -n  |grep :7474
  TCP    127.0.0.1:7474         0.0.0.0:0              LISTENING       15528
  TCP    127.0.0.1:7474         127.0.0.1:50884        TIME_WAIT       0
  TCP    127.0.0.1:7474         127.0.0.1:50885        TIME_WAIT       0
  TCP    127.0.0.1:7474         127.0.0.1:50886        TIME_WAIT       0
  TCP    127.0.0.1:7474         127.0.0.1:50888        TIME_WAIT       0
  TCP    127.0.0.1:7474         127.0.0.1:50889        TIME_WAIT       0
  TCP    127.0.0.1:7474         127.0.0.1:50898        TIME_WAIT       0
  TCP    127.0.0.1:7474         127.0.0.1:50899        TIME_WAIT       0
  TCP    127.0.0.1:7474         127.0.0.1:50913        ESTABLISHED     15528
  TCP    127.0.0.1:7474         127.0.0.1:50914        ESTABLISHED     15528
  TCP    127.0.0.1:7474         127.0.0.1:50915        ESTABLISHED     15528
  TCP    127.0.0.1:7474         127.0.0.1:50916        ESTABLISHED     15528
  TCP    127.0.0.1:7474         127.0.0.1:50917        ESTABLISHED     15528
  TCP    127.0.0.1:7474         127.0.0.1:50918        ESTABLISHED     15528
  TCP    127.0.0.1:50887        127.0.0.1:7474         TIME_WAIT       0
  TCP    127.0.0.1:50900        127.0.0.1:7474         TIME_WAIT       0
  TCP    127.0.0.1:50901        127.0.0.1:7474         TIME_WAIT       0
  TCP    127.0.0.1:50902        127.0.0.1:7474         TIME_WAIT       0
  TCP    127.0.0.1:50913        127.0.0.1:7474         ESTABLISHED     12356
  TCP    127.0.0.1:50914        127.0.0.1:7474         ESTABLISHED     12356
  TCP    127.0.0.1:50915        127.0.0.1:7474         ESTABLISHED     12356
  TCP    127.0.0.1:50916        127.0.0.1:7474         ESTABLISHED     12356
  TCP    127.0.0.1:50917        127.0.0.1:7474         ESTABLISHED     12356
  TCP    127.0.0.1:50918        127.0.0.1:7474         ESTABLISHED     12356
4

1 回答 1

0

通过绕过 localhost 的代理,我能够成功执行 startGraph。

脚步

1.我首先在windows命令提示符下使用[noproxy]选项对问题进行故障排除(验证此操作正确):

curl -v --noproxy localhost, http://localhost:7474/db/data/

2.然后在 RStudio 控制台上,我通过执行以下操作将我的 httr 配置(因为它是相同的底层 curl 接口)设置为使用 [noproxy] 选项:

rstudio_console>set_config(config(noproxy = "localhost"))  #set noproxy option

rstudio_console>set_config(config(verbose()))      #set verbose to view http messages

3.然后在没有选项的情况下执行startGraph:

rstudio_console>> graph = startGraph("http://localhost:7474/db/data")

4.瞧成功:

rstudio_console> graph 

< Graph > 

$version
[1] "3.0.1"
于 2016-05-18T06:32:05.620 回答