title: Socket IO net::ERR_CONNECTION_REFUSED
body: <p>I am trying to implement socket.io into my application which is hosted at Azurewebsites. <code>webapp</code></p>
  
  <p>Here is the server.js</p>
  
  <pre><code>var app = require('express')();
  var server = require('http').createServer(app);
  
  server.listen(process.env.PORT || 3001)
  
  app.get('/', function (req, res) {
    res.sendfile(__dirname + '/index.html');
  });
  
  var io = require('socket.io')(server);
  
  io.on('connection', function (socket) {
          console.log("Socket connected :"+socket.id);
   socket.emit('news', { hello: 'world' });
  });
  </code></pre>
  
  <p>And Here is the client side socket. index.html</p>
  
  <pre><code>&lt;script src="socket.io/socket.io.js"&gt;&lt;/script&gt;
              &lt;script&gt;
          var socket = io('http://localhost:3001');
          console.log("scoekt connect",socket)
        socket.on('connect', function(){ console.log('connected to socket'); });
        socket.on('error', function(e){ console.log('error' + e); });
  
      socket.on( 'news', function( data ){
      console.log("socket data",data);
  
      });&lt;/script&gt;
  </code></pre>
  
  <p>I am getting the below error
  <a href="https://i.stack.imgur.com/GWy4J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GWy4J.png" alt="enter image description here"></a></p>
  
  <p>I am not really sure whats is going wrong. Here is the structure of file-ing system</p>
  
  <pre><code>ROOT
  app/
  index.html
  server.js
  web.config
  </code></pre>
  
  <p>PS: this is an Angular2 application</p>
  
  <p>PS: I have checked all the suggested question based on this error but none solved my issue, thus i am posting this question.</p>