[英]Connecting to Cayley serving over localhost
I've followed the 'Getting Started' guide in Cayley's documentation and installed Cayley on my remote server: 我遵循了Cayley文档中的“入门”指南,并在远程服务器上安装了Cayley:
Getting Started: https://github.com/google/cayley
入门: https : //github.com/google/cayley
Server OS : CentOS 7.2.1511 服务器操作系统 :CentOS 7.2.1511
I've added cayley to my $PATH: 我已将cayley添加到$ PATH中:
echo $PATH
: echo $PATH
:
/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/csse/cayley/src/github.com/google/cayley
/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/csse/cayley/src/github.com/google/cayley
Here is my config file at /etc/cayley.cfg
这是我在
/etc/cayley.cfg
配置文件
{
"database": "leveldb",
"db_options": {
"cache_size_mb": 2,
"write_buffer_mb": 20
},
"db_path": "~/cayley/src/github.com/google/cayley/data/testdata.nq",
"listen_host": "127.0.0.1",
"listen_port": "64210",
"read_only": false,
"replication_options": {
"ignore_missing": false,
"ignore_duplicate": false
},
"timeout": 30
}
I serve cayley over http by simply doing: 我通过简单地通过http服务cayley:
cayley http
and the terminal outputs: 终端输出:
Cayley now listening on 127.0.0.1:64210
Cayley现在正在听127.0.0.1:64210
On my main machine (Mac OSX 10.10.5 Yosemite), I've used npm to install the cayley
package and written a test: 在我的主机(Mac OSX 10.10.5 Yosemite)上,我使用npm安装
cayley
软件包并编写了一个测试:
var cayley = require('cayley');
var client = cayley("137.112.104.107");
var g = client.graph;
g.V().All(function(err, result) {
if(err) {
console.log('error');
} else {
console.log('result');
}
});
However, it fails when I run it: node testconnection.js
但是,它在运行时失败:
node testconnection.js
error: Error: Invalid URI "137.112.104.107/api/v1/query/gremlin"
错误:错误:无效的URI“ 137.112.104.107/api/v1/query/gremlin”
I'd like to connect to Cayley and modify the database from my test. 我想连接到Cayley并从测试中修改数据库。 I've found a great powerpoint full of Cayley information:
我发现一个充满Cayley信息的强大简报:
https://docs.google.com/presentation/d/1tCbsYym1kXWWDcnRU9ymj6xP0Nvgq-Qhy9WDmqWcM-o/edit#slide=id.g3776708f1_0319 https://docs.google.com/presentation/d/1tCbsYym1kXWWDcnRU9ymj6xP0Nvgq-Qhy9WDmqWcM-o/edit#slide=id.g3776708f1_0319
As well as pertinent Cayley docs: 以及相关的Cayley文档:
- Overview Doc - 总览文件
- Configuration Doc - 配置文件
- HTTP API Doc -HTTP API文档
And a post on stackoverflow: 还有关于stackoverflow的文章:
- Cayley db user and password protection over HTTP connections - 通过HTTP连接的Cayley数据库用户和密码保护
But I'm struggling to come up with a way to connect Cayley (on my remote machine) with my local machine. 但是我正在努力想出一种将Cayley(在远程计算机上)与本地计算机连接的方法。 I'd like to connect with npm if possible, but am open to other options.
如果可能,我想与npm联系,但欢迎其他选择。 Where am I going wrong?
我要去哪里错了?
I've appended the "http://" to my ip, so now it reads http://137.112.104.107
. 我已经在IP上附加了“ http://”,因此现在显示为
http://137.112.104.107
。 At that point, I solved another issue by performing 那时,我通过执行
cayley init --config=/etc/cayley.cfg
as mentioned by the author here 作者在此处提到的
cayley init --config=/etc/cayley.cfg
I've also removed the listen_post
and listen_port
from my config file (each individually first, then both), yet have still have the same socket hang up
error. 我还从我的配置文件中删除了
listen_post
和listen_port
(首先分别一个一个,然后两个都删除),但是仍然有相同的socket hang up
错误。 Here's a printout of client
from the test script: 这是测试脚本中
client
的打印输出:
Client {
host: 'http://137.112.104.107',
request:
{ [Function]
get: [Function],
head: [Function],
post: [Function],
put: [Function],
patch: [Function],
del: [Function],
cookie: [Function],
jar: [Function],
defaults: [Function] },
graph: Gremlin { client: [Circular], query: [Function] },
g: Gremlin { client: [Circular], query: [Function] },
write: [Function: bound ],
delete: [Function: bound ],
writeFile: [Function: bound ]
}
Your Cayley server is listening on 127.0.0.1 / localhost and therefor not reachable from another machine. 您的Cayley服务器正在127.0.0.1 / localhost上侦听,因此无法从另一台计算机访问。 To be able to reach it from a virtual machine or another computer on your network it needs to bind to an interface that is reachable.
为了能够从网络上的虚拟机或另一台计算机访问它,它需要绑定到可访问的接口。
If you configure host: 0.0.0.0 and check what is your network IP (I assume: 137.112.104.107) and connect it, it should work or you need to open it or forward the port on your firewall (depending on your network). 如果您配置主机:0.0.0.0并检查什么是您的网络IP(我假设:137.112.104.107)并连接它,它应该可以工作,或者您需要打开它或转发防火墙上的端口(取决于网络)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.