title: Node and Angular socket error in browser console
body: <p>I am using Node(server) + Angular(client) to implement socket in my application.</p>
  
  <blockquote>
    <p>Angular bower.json socket components : "angular-socket-io":
    "^0.7.0","socket.io-client": "^1.7.2",</p>
    
    <p>Node js socket component in package.json : "socket.io": "^1.7.3",</p>
  </blockquote>
  
  <p>I am seeing this below web socket error in my chrome browser console :</p>
  
  <blockquote>
    <p>WebSocket connection to
    'wss://ireporter.apple.com/uitracker/socket.io/?EIO=3&amp;transport=websocket&amp;sid=4qBY-qoxEzUQZOvUAACb'
    failed: Error during WebSocket handshake: net::ERR_CONNECTION_RESET
    WrappedWebSocket @ VM43:161</p>
  </blockquote>
  
  <p>This error happens probably only in a production environment. Cannot remember seeing this error in when running the application in local.</p>
  
  <p>Also posting ONLY the socket related code from both server and client side :</p>
  
  <p>Node js server-side code </p>
  
  <h3>start.js file</h3>
  
  <pre><code>var express = require('express');
  var configure = require("./config/configure");
  var logger = require("./config/components/logger")
  var app = express();
  var server = require('http').Server(app);
  server.listen(process.env.PORT || config.port, function() {
      logger.info("Express server listening on port", config.port );
  });
  //Configure with all the basic middlewares and configs
  configure(app,server);
  </code></pre>
  
  <h3>configure.js file</h3>
  
  <pre><code>var socket = require('./middleware/socket/socket.js');
  module.exports = function (app,server) {
      app.use(socket(server));
  }
  </code></pre>
  
  <h3>socket.js file</h3>
  
  <pre><code>"use strict";
  
  var logger = require("../../components/logger");
  
  module.exports = function(server){
      var io = require('socket.io')(server, {path: '/appname/socket.io'});
      require('./socketServer.js')(io, logger);
  
      return function (req, res, next) {
          req.io = io;
          next();
      };
  };
  </code></pre>
  
  <h3>socketServer.js</h3>
  
  <pre><code>//export function for listening to the socket
  module.exports = function(io, logger) {
      io.on('connection', function(socket) {
          socket.on('notification:update', function(data) {
              io.emit('notification:update', data);
          });
      });
  };
  </code></pre>
  
  <p>Angular js Client Side code :</p>
  
  <h3>Socket.js</h3>
  
  <pre><code>MyApp.factory('Socket', function ($rootScope) {
      var socket = io.connect('' , {path: '/appname/socket.io'});
      return {
          on: function (eventName, callback) {
              socket.on(eventName, function () {
                  var args = arguments;
                  $rootScope.$apply(function () {
                      callback.apply(socket, args);
                  });
              });
          },
          emit: function (eventName, data, callback) {
              socket.emit(eventName, data, function () {
                  var args = arguments;
                  $rootScope.$apply(function () {
                      if (callback) {
                          callback.apply(socket, args);
                      }
                  });
              })
          }
      };
  });
  </code></pre>
  
  <p>notificationController.js</p>
  
  <pre><code>Socket.on('notification:update', function(data) {
  });
  </code></pre>
  
  <p>-- Could anyone suggest how to resolve the console error? </p>