Hi,
I first tried to replicate your issue using this simplified script:
const Aerospike = require('aerospike')
const client = new Aerospike.Client({
hosts: 'localhost:32838'
})
client.connect((error) => { if (error) throw error })
setTimeout(async () => {
const key = new Aerospike.Key('test', 'test', 'test')
await client.put(key, { str: 'abc' })
const result = await client.get(key)
console.log(result)
client.close()
})
That works as expected. So I tried to run the example code from the tutorial you linked. I’ve pulled the whole code out of that tutorial together into one single script here: node_clusters.js · GitHub.
On start, each worker connects to the Aerospike cluster as expected:
$ AEROSPIKE_HOSTS=localhost:32838 NODE_DEBUG=server node node_clusters.js
SERVER 37523: worker 1 starting
SERVER 37524: worker 2 starting
SERVER 37523: Connected to Aerospike cluster
SERVER 37524: Connected to Aerospike cluster
SERVER 37525: worker 3 starting
SERVER 37526: worker 4 starting
SERVER 37525: Connected to Aerospike cluster
SERVER 37526: Connected to Aerospike cluster
SERVER 37523: incoming request on worker 1
Maybe you can try to enable debug logs, to verify that the client is trying to connect to the right address, e.g.
const Aerospike = require('aerospike')
const client = new Aerospike.Client({
hosts: 'localhost:32838',
log: {
level: Aerospike.log.DEBUG,
file: process.stdout.fd
}
})
client.connect((error) => { if (error) throw error })
setTimeout(async () => {
const key = new Aerospike.Key('test', 'test', 'test')
await client.put(key, { str: 'abc' })
const result = await client.get(key)
console.log(result)
client.close()
})
Running this script, you should see something like this:
$ node test.js
Jul 08 2020 01:25:38 UTC: DEBUG(43516) [config.cc:234] [config_from_jsobject] - Parsing global policies: success
Jul 08 2020 01:25:38 UTC: DEBUG(43516) [config.cc:322] [config_from_jsobject] - Built as_config instance from JS config object
Jul 08 2020 01:25:38 UTC: DEBUG(43516) [client.cc:80] [New] - Aerospike client initialized successfully
Jul 08 2020 01:25:38 UTC: DEBUG(43516) [events.cc:57] [push] - Cluster event 0 triggered by node "BB9040011AC4202" ([::1]:32838)
Jul 08 2020 01:25:38 UTC: DEBUG(43516) [events.cc:57] [push] - Cluster event 0 triggered by node "BB9030011AC4202" (192.168.1.11:32835)
Jul 08 2020 01:25:38 UTC: DEBUG(43516) [client.cc:99] [Connect] - Successfully connected to cluster: Enjoy your cake!
Jul 08 2020 01:25:38 UTC: DEBUG(43516) [command.cc:66] [Callback] - Executing JS callback for Connect command
Jul 08 2020 01:25:38 UTC: DEBUG(43516) [put_async.cc:73] [PutAsync] - Sending async put command
Jul 08 2020 01:25:38 UTC: DEBUG(43516) [command.cc:66] [Callback] - Executing JS callback for Put command
Jul 08 2020 01:25:38 UTC: DEBUG(43516) [get_async.cc:56] [GetAsync] - Sending async get command
Jul 08 2020 01:25:38 UTC: DEBUG(43516) [command.cc:66] [Callback] - Executing JS callback for Get command
Record {
key: Key {
ns: 'test',
set: 'test',
key: 'test',
digest: <Buffer ee d5 e3 61 f7 0d c4 ab 19 71 3f c0 f6 87 74 62 8c a8 32 f6>
},
bins: { str: 'abc' },
ttl: -1,
gen: 14
}
Jul 08 2020 01:25:38 UTC: DEBUG(43516) [client.cc:114] [Close] - Closing the connection to aerospike cluster