我正在尝试运行https://github.com/hazelcast/hazelcast-nodejs-client
的“使用客户端”部分中提供的基本示例代码我收到连接拒绝错误。我在我的Mac和我的PC机上尝试了相同的结果。他们正在运行Node v6.9.1。我没有任何特殊的防火墙设置。甚至尝试完全转向Windows防火墙。
我有什么遗失的吗?
[DefaultLogger] WARN at ClientConnection: Could not connect to address localhost:5701
{ Error: connect ECONNREFUSED 127.0.0.1:5701
at Object.exports._errnoException (util.js:1026:11)
at exports._exceptionWithHostPort (util.js:1049:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1085:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 5701 }
Unhandled rejection Error: Unable to connect to any of the following addresses: localhost:5701
at Immediate.<anonymous> (C:\Users\Jennie Lyn\node_modules\hazelcast-client\lib\invocation\ClusterService.js:95:33)
at runCallback (timers.js:637:20)
at tryOnImmediate (timers.js:610:5)
at processImmediate [as _immediateCallback] (timers.js:582:5)
首先我创建了一个空节点项目:
npm install hazelcast-client --save
然后用:
创建了一个js文件var HazelcastClient = require('hazelcast-client').Client;
var person = {
firstName: "Joe",
lastName: "Doe",
age: 42
};
var map;
HazelcastClient.newHazelcastClient().then(function (hazelcastClient) {
map = hazelcastClient.getMap("personMap");
map.put(1, person).then(function (val) {
// prints previous value for key `1`
console.log(val);
});
map.get(1).then(function (value) {
console.log(value);
})
});
这就是所有文件都要做的。使用hazelcast-client for nodejs是否需要在localhost上启动单个客户端集群?
答案 0 :(得分:1)
开始之前
start hazelcast node http://gamov.io/images/before_nodejs_client.gif
让我知道它是否有效
干杯, 维克