Skip to content

Instantly share code, notes, and snippets.

@nairihar
Created July 14, 2022 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nairihar/633a09ee08c19167ab39215256478410 to your computer and use it in GitHub Desktop.
Save nairihar/633a09ee08c19167ab39215256478410 to your computer and use it in GitHub Desktop.
Scaling up Node.js Socket Server with Nginx and Redis | subscriber.js & publisher.js
const redis = require('redis');
const publisher = redis.createClient();
publisher.publish('my channel', 'hi');
publisher.publish('my channel', 'hello world');
const redis = require('redis');
const subscriber = redis.createClient();
subscriber.on('message', (channel, message) => {
console.log(`Message "${message}" on channel "${channel}" arrived!`)
});
subscriber.subscribe('my channel');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment