Comments (1)
Sorry for the late response. I was busy with other projects.
The client should automatically reconnect to the cluster once it comes back up. If the cluster goes down while your express app is running, you should see one of these two errors:
AerospikeError: Failed to connect
AerospikeError: Cluster is empty
You could get the error AerospikeError: Not connected
if you are starting your express app while the Aerospike cluster is down. But I wasn't able to reproduce this error if the app is already running when the cluster goes down.
Here is the simple demo app I was using for testing:
$ cat express.js
const express = require('express')
const session = require('express-session')
const AerospikeStore = require('aerospike-session-store')(session)
var app = express()
app.use(session({
secret: '123456789QWERTY',
store: new AerospikeStore({
namespace: 'express',
set: 'session',
ttl: 86400, // 1 day
hosts: process.env.AEROSPIKE_HOSTS
}),
resave: false,
saveUninitialized: false
}))
app.get('/', (req, res) => {
var sess = req.session
if (sess.views) {
sess.views++
res.setHeader('Content-Type', 'text/html')
res.write('<p>views: ' + sess.views + '</p>')
res.end()
} else {
console.log('initializing new session')
sess.views = 1
res.end('welcome to the session demo. refresh!')
}
console.log('views=', sess.views)
})
app.listen(3000, () => {
console.log('Session store example listening at http://localhost:3000/')
})
I start this app, hit the root path a few times in the browser and then shut down the Aerospike server. When reloading the page, the error I see is AerospikeError: Failed to connect
. But once I restart the server, the client automatically reconnects:
$ AEROSPIKE_HOSTS=192.168.33.10:3000 node ./express.js
Session store example listening at http://localhost:3000/
initializing new session
views= 1
views= 2
views= 3
views= 4
views= 5
AerospikeError: Failed to connect: BB9EB63B2005452 192.168.33.10:3000
at Function.AerospikeError.fromASError (/Users/jhecking/aerospike/aerospike-session-store-expressjs/node_modules/aerospike/lib/aerospike_error.js:113:10)
at Client.DefaultCallbackHandler [as callbackHandler] (/Users/jhecking/aerospike/aerospike-session-store-expressjs/node_modules/aerospike/lib/client.js:71:72)
at getCb (/Users/jhecking/aerospike/aerospike-session-store-expressjs/node_modules/aerospike/lib/client.js:840:10)
AerospikeError: Failed to connect: BB9EB63B2005452 192.168.33.10:3000
at Function.AerospikeError.fromASError (/Users/jhecking/aerospike/aerospike-session-store-expressjs/node_modules/aerospike/lib/aerospike_error.js:113:10)
at Client.DefaultCallbackHandler [as callbackHandler] (/Users/jhecking/aerospike/aerospike-session-store-expressjs/node_modules/aerospike/lib/client.js:71:72)
at getCb (/Users/jhecking/aerospike/aerospike-session-store-expressjs/node_modules/aerospike/lib/client.js:840:10)
views= 6
views= 7
views= 8
from aerospike-session-store-expressjs.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aerospike-session-store-expressjs.