<commit_before>var http = require('http');
var express = require('express');
var redis = require('redis');
var path = require('path');
var socketio = require('socket.io');

//get environment variables
var port = process.env.PORT || 80;
var redisPort = process.env.REDIS_PORT || 6379;
var redisHost = process.env.REDIS_HOST || "proxybug.redis.cache.windows.net";
var redisPassword = process.env.REDIS_PASSWORD || "<PASSWORD>=";

//debug switches
redis.debug_mode = true;

console.log('starting up...');

//connect to redis
var rc = redis.createClient(redisPort, redisHost);
rc.auth(redisPassword, function() {
  console.log('connected to redis');
});

var app = express();
var server = http.createServer(app);
var io = socketio.listen(server);
//io.set('origins', '*:*');
app.use(express.static(path.join(__dirname, '/public'), { index:['index.html'] } ));

//start the server
server.listen(port);

//respond to websocket connections
io.on('connection', function (socket) {
  console.log('client connected');
  rc.on("subscribe", function(channel, count) {
    console.log('subscribed to ' + channel);
  });

  rc.on("message", function(channel, message) {
    var obj = JSON.parse(message);
    console.log(obj);
  	socket.emit('news', obj);
  });

  socket.on("disconnect", function(reason) {
    rc.unsubscribe();
    rc.end();
  });

  rc.subscribe("proxied");
});<commit_msg>trying to fix reconnect<commit_after>var http = require('http');
var express = require('express');
var redis = require('redis');
var path = require('path');
var socketio = require('socket.io');

//get environment variables
var port = process.env.PORT || 80;
var redisPort = process.env.REDIS_PORT || 6379;
var redisHost = process.env.REDIS_HOST || "proxybug.redis.cache.windows.net";
var redisPassword = process.env.REDIS_PASSWORD || "<PASSWORD>=";

//debug switches
redis.debug_mode = true;

console.log('starting up...');

//connect to redis
var rc = redis.createClient(redisPort, redisHost);
rc.auth(redisPassword, function() {
  console.log('connected to redis');
});

var app = express();
var server = http.createServer(app);
var io = socketio.listen(server);
//io.set('origins', '*:*');
app.use(express.static(path.join(__dirname, '/public'), { index:['index.html'] } ));

//start the server
server.listen(port);
server.on('close', fucntion() {
  rc.end();
});

//respond to websocket connections
io.on('connection', function (socket) {
  console.log('client connected');
  rc.on("subscribe", function(channel, count) {
    console.log('subscribed to ' + channel);
  });

  rc.on("message", function(channel, message) {
    var obj = JSON.parse(message);
    console.log(obj);
  	socket.emit('news', obj);
  });

  socket.on("disconnect", function(reason) {
    rc.unsubscribe();
  });

  rc.subscribe("proxied");
});
{'fraction_non_alphanumeric': 0.18665239114917917, 'fraction_numerical': 0.004282655246252677, 'mean_word_length': 4.827442827442828, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3166050', 'n_tokens_mistral': 935, 'n_tokens_neox': 914, 'n_words': 201}