Reputation: 11776
Scenario: PHP app that publishes to redis channel called "message" sitting on IP 1.2.3.4
How to connect from node to that channel on that IP?
var listener = redis.createClient();
listener.subscribe('message', /* ? '1.2.3.4' ? */);
listener.on("messages", function(channel, message) {
// do something with data
});
Upvotes: 4
Views: 1030
Reputation: 61783
I assume you are using node_redis. You can specify the host 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');
It is in the documentation which is pretty good and I think you should read it completely.
P.S: When you make redis available for remote host(s) I think you should have your firewall setup properly to deny access from other IPs(whitelist).
Upvotes: 5