Leverage the power of Azure Redis Cache to efficiently store Node JS express

I recently attempted to create an Express 4 Web App using Azure. I came across multiple articles that suggested using Azure Redis Cache for storing sessions. However, I am unsure about the proper way to connect my web app to the redis cache.

var session = require('express-session');
var redis = require('redis');
var RedisStore = require('connect-redis')(session); 
var client = redis.createClient(6380, 'MyHost', { auth_pass: 'MyPass', tls: { servername: 'MyHostName' } });

app.use(session({
    secret: 'keyboard cat',
    key: 'sid',
    resave: false,
    saveUninitialized: false,
    store: new RedisStore(client);
}));

Unfortunately, when I run the application, an error occurs with the message "TypeError: this.client.unref is not a function". Could anyone provide guidance on resolving this issue? Thank you!

Answer №1

One possible error could be found in the constructor of RedisStore.

To resolve this issue, modify the code line store: new RedisStore(client); to:

store: new RedisStore({client: client});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Retrieve a segment of a video file from an AWS S3 bucket in Node.js using the range parameter

Here is a code snippet that successfully reads a file by range: let filePath = 'assets/video/' + req.body.key; let fileStats = fs.statSync(filePath); let totalSize = fileStats.size; let range = req.headers.range; let parts = range.replace(/bytes ...

Encountering the error "Invalid parameter: redirect_uri" while attempting to authenticate with KeyCloak using NODE.JS

In my Node.JS (express) project, I am utilizing a helpful NPM package called keycloak-connect to establish a connection with a keycloak server. While trying out the default protection mechanism for a specific route: app.get( '/about', keycloak ...

Exploring the world of Node.js, JSON, SQL, and database tables

Hello everyone, I have been working on a project using Node.js and Express framework. My current goal is to create a client-side page that allows users to input form data into a MySQL database. I have managed to successfully insert and retrieve data from ...

Why aren't variables showing up on the right when using writeFileSync in Node.js?

I'm attempting to insert a variable as ${Y} but instead of getting the actual data in Y, my output is showing (how can I write variable ${Y}). Does anyone have a solution for this? const fs = require('fs'); const Y = fs.readFileSync('./ ...

What could be causing my function to output unicode replacement characters instead?

As I work on enhancing password security by implementing encryption, my goal is to store the hashes and perform encryption/decryption during signup/login processes. The encryption process works smoothly, converting from utf8 to hex without any issues. Howe ...

Fetching data from an Angular Universal server API

Recently, I updated my application to Angular 6 + Universal and it has been a positive experience overall. However, there are two specific issues that I am currently facing. I would greatly appreciate assistance in resolving both problems: 1- Is there a w ...

Is it possible to log the response body when encountering errors in a Mocha test

Is it plausible to print out the contents of the response body whenever a test fails with an error while running mocha tests using npm run test? chai.request(server) .post('/') .set('X-Access-Token', testUser.accessToken) .send( ...

Receive a promise from an assertion within the 'then' block

Attempting to create a sequence of selenium commands using 'then' has left me stumped on how to return a promise from asserts. The warning message I keep encountering is as follows: (node:18772) UnhandledPromiseRejectionWarning: Unhandled promise ...

What is the best way to save files on a web hosting platform?

Hey everyone, I hope you're all having a good evening. Recently, I developed a React Application that allows users to upload and store images both locally and on MongoDB along with some additional data. During local development, everything was working ...

Halting execution: Trying to use the keyword 'import' which is not allowed here

0. April 2023: error cannot be reproduced anymore see here The error is no longer replicable due to bug fixes in react-scripts 5.0.1. 1 Even though the error is gone, the question and my self-answer still seem relevant to Angular users and others as we ...

Identify the specific path that triggers the PayloadTooLargeError

Our NodeJS app built with Express is encountering PayloadTooLargeError messages that we can't seem to track down. The challenge lies in the fact that we are unable to pinpoint what's causing it or recreate the issue. Furthermore, the error messag ...

NPM is downloading an incorrect version of Angular (8.1.0)

After running the command "npm run ng --version", I see version 6.4.1 displayed. npm run ng --version However, when I run the command "npm install -g @angular/cli", it installs version 8.1.0 and generates an error. This is confusing to me. npm install - ...

node js retrieves information from the request body

Hey there! I'm diving into the world of Node.js and JavaScript, but I've hit a roadblock. I'm trying to fetch data from a URL using node-fetch, then parse it as JSON. However, I keep running into the issue of getting 'undefined' in ...

Steps to resolve the 'form' variable being assigned a value but never used in axios:

I am encountering an issue with a contact form that utilizes React with axios on the frontend and Express with nodemailer on the backend while running locally. The expected outcome is for me to receive an email when I click the "Submit" button. However, up ...

Integrating an AKS cluster with an application gateway in Kubernetes. Several websites (not sub pages) directing to a shared IP address

In the past, our system functioned with Docker swarm and multiple services like nginx, nodejs/auth, and web app all linked to an application gateway. Each tenant/customer had their own URL mapped to the app gateway IP, allowing for customized pages based o ...

Unable to locate request object during post request

I've created a pug form with the following structure: extends layout block content h1 David A Hines h2 #{posts[0].title} p #{posts[0].body} div form(action='/insert_post',method='post') div(id='title_div' ...

Implementing logout in a Node.js and Express application with Auth0: A step-by-step guide

I am currently working with a Node.js and Express server, leveraging Auth0 for authentication. I have been trying to figure out how to enable logout functionality when the client accesses the "/exit" route in my application. Here is an overview of the rele ...

After deploying to the production server, Next.js is failing to fetch images using the image URL

Our production deployment setup includes a network of 3 linux machines, with two dedicated to deployment and one serving as an nginx proxy. For development deployment, we utilize a separate linux machine. Within our frontend (built using the nextjs framew ...

What is the best way to create a backup copy of my project using git?

To ensure the safety of my project, I took the necessary steps to back it up. First, I initialized a repository using git init Following that, I committed all files by executing git add . git commit -am "first commit" Now, the next step involves pushin ...

NodeJS Request Body Not Populated

Currently operating with node using [email protected] and [email protected]. Within my jade page, there exists a property like this: input(type='text',class='form-control', placeholder="Username", name='username', ...