title: socket.io - 'connect' event does not fire on the client
body: <p>I am trying to get started with node.js and socket.io.<br>
  I have a very (<strong>very</strong>) simple client-server test application and i can't get it to work.<br>
  The system is set up on a windows machine with an apache server.<br>
  The apache is running on <code>port 81</code> and the the socket.io is set up to listen to <code>port 8001</code></p>
  
  <p><strong>Server</strong> - server.js</p>
  
  <pre><code>var io = require('socket.io').listen(8001);
  
  io.sockets.on('connection', function (socket) {
      console.log('\ngot a new connection from: ' + socket.id + '\n');
  });
  </code></pre>
  
  <p><strong>Client</strong> - index.html</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;node-tests&lt;/title&gt;
      &lt;script type="text/javascript" src="http://localhost:8001/socket.io/socket.io.js"&gt;    &lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          var socket = io.connect('http://localhost', { port: 8001 });
  
          socket.on('connect', function () {
              alert('connect');
          });
  
          socket.on('error', function (data) {
              console.log(data || 'error');
          });
  
          socket.on('connect_failed', function (data) {
              console.log(data || 'connect_failed');
          });
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>After starting my server using <code>node server.js</code> the standard (expected) output is written to the server console:</p>
  
  <pre><code>info: socket.io started
  </code></pre>
  
  <p>When I open <code>index.html</code> in the browser (chrome in my case - didn't test on other browsers) the following log is written to the server console:</p>
  
  <pre><code>info: socket.io started
  debug: served static content /socket.io.js
  debug: client authorized
  info: handshake authorized 9952353481638352052
  debug: setting request GET /socket.io/1/websocket/9952353481638352052
  debug: set heartbeat interval for client 9952353481638352052
  debug: client authorized for
  
  got a new connection from: 9952353481638352052
  
  debug: setting request GET /socket.io/1/xhr-polling/9952353481638352052?t=1333635235315
  debug: setting poll timeout
  debug: discarding transport
  debug: cleared heartbeat interval for client 9952353481638352052
  debug: setting request GET /socket.io/1/jsonp-polling/9952353481638352052?t=1333635238316&amp;i=0
  debug: setting poll timeout
  debug: discarding transport
  debug: clearing poll timeout
  debug: clearing poll timeout
  debug: jsonppolling writing io.j[0]("8::");
  debug: set close timeout for client 9952353481638352052
  debug: jsonppolling closed due to exceeded duration
  debug: setting request GET /socket.io/1/jsonp-polling/9952353481638352052?t=1333635258339&amp;i=0
  ...
  ...
  ...
  </code></pre>
  
  <p>In the browsers console I get:</p>
  
  <pre><code>connect_failed
  </code></pre>
  
  <p>So it seems like the client is reaching the server and trying to connect, and the server is authorizing the handshake but the <code>connect</code> event is never fired in the client, instead the connect method reaches its <code>connect timeout</code> and <code>max reconnection attempts</code> and gives up returning <code>connect_failed</code>.</p>
  
  <p>Any help\insight on this would be helpful.</p>
  
  <p>Thank you</p>