Hi,
I was having a look at the logs after a deploy to production (AWS).
I can see that and found some ways of fixing on forums but don’t want to break everything. What do you advice to fix this warning? Or I don’t have to care much and can live with it? Any ideas?
Warning: connect.session() MemoryStore is not designed for a production environment, as it will leak memory, and will not scale past a single process. App listening at http://localhost:3000
Sounds like you do not have Redis enabled…I would enable that to try and resolve.
On your target settings, enable Redis:
You may also have to change your server connect settings:
Thanks. I done it. But I got this message when I deploy :
Bringing all services up …
ERROR: Service “redis” uses an undefined network “proxy”
Error Launching Services!
Dave
June 28, 2021, 7:15pm
4
Try setting your Usage in targets to Production see if that helps?
done. It changes nothing, can’t deploy, still got the above ERROR about redis and proxy.
Dave
June 28, 2021, 7:26pm
6
I don’t think it should have changed for any reason but what does the following file contain?
\lib\setup\session.js
Mine looks like this:
const session = require('express-session'); //(Object.assign({ secret: config.secret }, config.session));
const config = require('./config');
const options = config.session;
if (!options.secret) {
options.secret = config.secret;
}
if (options.store) {
if (options.store.$type == 'redis') { // https://www.npmjs.com/package/connect-redis
const RedisStore = require('connect-redis')(session);
options.store = new RedisStore(Object.assign({
client: global.redisClient
}, options.store));
}
if (options.store.$type == 'file') { // https://www.npmjs.com/package/session-file-store
const FileStore = require('session-file-store')(session);
options.store = new FileStore(options.store);
}
if (options.store.$type == 'database') { // https://www.npmjs.com/package/connect-session-knex
const KnexStore = require('connect-session-knex')(session);
options.store = new KnexStore(options.store);
}
}
module.exports = session(options);
Also have you got:
"connect-redis": "^5.0.0",
and
"express-session": "^1.17.1",
installed and included in your package.json file?
Dave
June 28, 2021, 7:30pm
7
Sorry I must have missed that, looked straight at the error (ref me asking about Production ).
Here is the \lib\setup\session.js :
const session = require(‘express-session’); //(Object.assign({ secret: config.secret }, config.session));
const config = require(’./config’);
const options = config.session;
if (!options.secret) {
options.secret = config.secret;
}
if (options.store) {
if (options.store.$type == ‘redis’) { // https://www.npmjs.com/package/connect-redis
const RedisStore = require(‘connect-redis’)(session);
options.store = new RedisStore(Object.assign({
client: global.redisClient
}, options.store));
}
if (options.store.$type == 'file') { // https://www.npmjs.com/package/session-file-store
const FileStore = require('session-file-store')(session);
options.store = new FileStore(options.store);
}
if (options.store.$type == 'database') { // https://www.npmjs.com/package/connect-session-knex
const KnexStore = require('connect-session-knex')(session);
options.store = new KnexStore(options.store);
}
}
module.exports = session(options);
and I got both you mention in package.json.
“connect-redis”: “^5.0.0”,
“express-session”: “^1.17.1”,
Dave
June 28, 2021, 7:37pm
9
Maybe @George could offer you far better ideas for a resolution than I can…
Will keep digging in to it in the meantime though…
I have disable redis … but still got the ERROR message, I guess there is something to remove manually somewhere. Can’t deploy (
So. Got it solved. The issue was that the URL for web server was not https.
Now it’s working like a charm.
Maybe for such “blocking” point would be nice to get an alert as it’s a “known condition”. It’s a good UX practice and would solve a lot of issues like this one. what you think? @George
And as mentioned by @mebeingken it was a redis issue. When redis set up. The log after a deploy looks show redis and the warning is not here anymore. Thanks for your support.
1 Like
George
June 28, 2021, 10:16pm
12
Weird that this was your issue.
Redis is separate from that - running just as an additional docker service.
Anyway glad it is all resolved.
yep, I changed nothing except that.
George
June 28, 2021, 10:30pm
14
I think that was the actual error and by just reapplying the docker settings you solved it.
1 Like