var app = require('http').createServer(handler)
  , io = require('socket.io').listen(app)
  , fs = require('fs');

var port = process.env.PORT || 5000;
console.log("Listening on " + port);
 
app.listen(port);

function handler (req, res) {
  fs.readFile(__dirname + '/index.html',
  function (err, data) {
    if (err) {
      res.writeHead(500);
      return res.end('Error loading index.html');
    }
    res.writeHead(200);
    res.end(data);
  });
}
redis = require("redis");

var pub = redis.createClient();

io.sockets.on('connection', function (client) {
	var sub = redis.createClient();

	console.log("CLIENT CONNECTED!")

	sub.on("message", function (channel, message) {
		console.log("RECEIVED CHANNEL:" +channel);
		client.send(message);
	});

	client.on("message", function (msg) {
		console.log("=====START=====")
	    console.log(msg);
	    if(msg.type == "chat"){
	        pub.publish("kanal:" + msg.kanal, msg.message);
	    }
	    else if(msg.type == "setUsername"){
	    	console.log("SUB= CH:" + msg.kanal)
			client.send("SELAM");
			sub.subscribe("kanal:" + msg.kanal);
			pub.publish("kanal:" + msg.kanal, "CONNECTED USER");
	    }

	    console.log("=====END=====")
	});

	client.on('disconnect', function () {
	    sub.quit();
	});
	 
 	
});
@@ -447,16 +447,17 @@
   %7D);%0A%7D%0A
+%09
 redis = 
@@ -471,24 +471,120 @@
 (%22redis%22);%0A%0A
+if (process.env.REDISTOGO_URL) %7B%0A%09var rtg   = require(%22url%22).parse(process.env.REDISTOGO_URL);%0A%09
 var pub = re
@@ -577,29 +577,40 @@
 %0A%09var pub = 
+require(%22
 redis
+%22)
 .createClien
@@ -611,18 +611,121 @@
 eClient(
-);
+rtg.port, rtg.hostname);%0A%09%0A%09pub.auth(rtg.auth.split(%22:%22)%5B1%5D);%0A%7D else %7B%0A%09var pub = redis.createClient();%0A%7D
 %0A%0Aio.soc
@@ -762,24 +762,59 @@
  (client) %7B%0A
+%09if (process.env.REDISTOGO_URL) %7B%0A%09
 %09var sub = r
@@ -808,29 +808,40 @@
 %09%09var sub = 
+require(%22
 redis
+%22)
 .createClien
@@ -842,18 +842,125 @@
 eClient(
-);
+rtg.port, rtg.hostname);%0A%09%0A%09%09sub.auth(rtg.auth.split(%22:%22)%5B1%5D);%0A%09%7D else %7B%0A%09%09var sub = redis.createClient();%0A%09%7D
 %0A%0A%09conso

Configure redis to go