Node.JS, subscribing to a channel at a given IP address

Scenario: A PHP application that publishes a redis feed called a "message" sitting on IP 1.2.3.4

How to connect from node to this channel on this IP ?

var listener = redis.createClient(); listener.subscribe('message', /* ? '1.2.3.4' ? */); listener.on("messages", function(channel, message) { // do something with data }); 
+4
source share
1 answer

I assume you are using node_redis . You can specify the host that you are using:

 redis.createClient(port, host, options) --- Create a new client connection. port defaults to 6379 and host defaults to 127.0.0.1. 

So you should use:

 redis.createClient('1.2.3.4'); 

This is pretty good in the documentation, and I think you should read it completely.

PS: When you make redis available to remote hosts, I think you should configure the firewall correctly to block access to other IP addresses (whitelist).

+5
source

All Articles