title: Socket.io failed: WebSocket is closed before the connection is established
body: <h1>The Issue</h1>
  <p>My Twitter streaming app using Socket.io works okay when visiting the site with the IP address and port, but live streaming throws an error, when using the domain name to access the site. </p>
  <p>Try the links below, and open up the developer tools, to see the error</p>
  <h3>Visiting site using the domain name (<a href="http://sentiment-sweep.com" rel="nofollow noreferrer">http://sentiment-sweep.com</a>)</h3>
  <p>Hundreds of socket errors following this format:</p>
  <pre><code>WebSocket connection to 
  'ws://sentiment-sweep.com/socket.io/?EIO=3&amp;transport=websocket&amp;sid=guBmeCqsOr22CTsWAAC0' 
  failed: WebSocket is closed before the connection is established.
  </code></pre>
  <h3>Visiting the site using IP and Port (<a href="http://XXX.XX.XXX.XX:3003" rel="nofollow noreferrer">http://XXX.XX.XXX.XX:3003</a>)</h3>
  <p>Initially a few of the above socket errors, but then affter 10-15 seconds the app starts to work fine</p>
  <h1>Background</h1>
  <p>I made this Node app for a University project few years back. I keep it updated. It uses Socket.io and the Twitter API to stream live Tweets, calculate the sentiment and display results visually using D3. I use NGINX for port forwarding.</p>
  <p>For reference, here is my git repo: <a href="https://github.com/Lissy93/twitter-sentiment-visualisation" rel="nofollow noreferrer">https://github.com/Lissy93/twitter-sentiment-visualisation</a></p>
  <p>Recently I made a small HTML/ CSS change, and updated a couple of dependencies, and that's when this strange socket.io issue started</p>
  <h1>What I've tried so far</h1>
  <ul>
  <li>Changing the port - no difference</li>
  <li>I use <code>io.connect();</code> with no params to connect</li>
  <li>Including socket.io locally, rather than from CDN</li>
  <li>Could it have something to do with my site being non-SSL</li>
  <li>Locally it works totally fine, and faster and less of a delay than the API version</li>
  </ul>
  <p>Has anyone seen an issue similar to this before?</p>