session - No cookie received on Elastic Beanstalk with Elasticache -


problem:

after logging deployed node app on elastic beanstalk, never receive cookie, , whenever refresh page through browser, logged out.

here express-session setup:

app.use(session({     store: new redisstore({       client: redisclient,       host: process.env.redis_host,       port: process.env.redis_port     }),     secret: process.env.session_secret,     resave: false,     saveuninitialized: false // no cookie received until successful login })); 

in development (after login): enter image description here

in production (after login): enter image description here

so while able "log in", unable have persistent session through refresh because there never cookie sent back.

possible reasons have ruled out:

  • elasticache: have set elasticache instance redis.

  • security groups: have configured inbound security group accept incoming tcp connections elastic beanstalk security group. i've tested using ssh connect beanstalk, installing redis-cli, , connecting primary endpoint successfully.

  • load balancer: elastic beanstalk instance single node , not use load balancing, results same when use application controlled sticky sessions load balancing.

do guys have idea wrong?

the issue in configuration:

having "client" key in "new redisstore" overwrites sibling "host" , "port" keys.

the correct configuration following:

const redisclient = redis.createclient({   host: process.env.redis_host,   port: process.env.redis_port });  app.use(session({   store: new redisstore({     client: redisclient   }),   secret: process.env.session_secret,   resave: false,   saveuninitialized: false })); 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -