Created
July 14, 2022 19:44
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const redis = require('redis'); | |
const publisher = redis.createClient(); | |
publisher.publish('my channel', 'hi'); | |
publisher.publish('my channel', 'hello world'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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