title: Socket.io on connect not working
body: <p>I've seen this problem before and I've read through all the docs I can find, but somehow I'm just not seeing it in my code. It must be something very trivial I am getting wrong, but any help would be appreciated. </p>
  
  <p>The issue is that I can't get socket.io to connect to the server. On the server side the 'connection established' shows up, but none of my other console logs on server or client sides. I've followed the documentation of the socket.io folks pretty closely.</p>
  
  <p>Here is the server side (in node.js/express btw): </p>
  
  <pre><code>module.exports = function(server){
    console.log('what is server', server);
    var io = require('socket.io')(server);
    var ss = require('socket.io-stream');
    var fs = require('fs');
    var serveIndex = require('serve-index');
    var path = require('path');
  
  
  io.on('connection', function(socket) {
    console.log('connection established');
    io.sockets.on('songName', function(data) {
      console.log('in back side socket.on');
      var stream = ss.createStream();
      var filename = serveIndex('/playlist/', path.basename(data.name), '.mp3');
      res.writeHead(200, {
        'Content-Type': 'audio/mpeg' || 'audio/mp4',
        'Content-Length': stat.size
      });
      ss(socket).emit('audioStream', stream, { name: filename });
      fs.createReadStream(filename).pipe(stream);
    });
  });
  };
  </code></pre>
  
  <p>And here is the client side (and sanity check2 console log fires): </p>
  
  <pre><code>console.log('sanity check2');
  
  $(document).ready(function(){
  
    window.AudioContext = window.AudioContext||window.webkitAudioContext;
      context = new AudioContext();
  
    var socket = io.connect('http://localhost:5000/socket');
  
    socket.on('connection', function(){
      console.log('front end socket connected succesfully');
      socket.emit('songName', {name: 'LaNegra'});
    })
  
    socket.on('audioStream', function(stream) {
      console.log('in front side socket.on');
      var source = context.createMediaStreamSource(stream);
      source.connect(context.destination);
    });
  
  
  });
  </code></pre>
  
  <p>Again, this is a pretty simple problem most likely, so I apologize in advance.</p>
  
  <p>EDIT: Sorry I should have mentioned this, but the server side code is in a file that is /sockets/socket.js and in app.js I call it using app.use().</p>