title: Hapi.js + Socket.io together
body: <p>I want to run Hapi.js together with socket.io. That would be great if I had separate connections for socket.io and hapi app using the same server because I want to use Hapi auth cookies in my socket</p>
  
  <p>I tried few solutions, but none of them is working and my server is crashing. I tried to run socket.io on the same port as hapi and my app started, but I got "This localhost page can not be found" error. What did I do wrong? Any help will be appreciated</p>
  
  <p>Here's my code:</p>
  
  <pre><code>const Hapi = require('hapi');
  const server = new Hapi.Server();
  const Config = require('./config/config.js');
  const port = Number(process.env.PORT || 3000);
  const io = require("socket.io")(port);
  
  server.connection({
      port: port
  });
  
  // my routes are here...
  
  io.on("connection", function (socket) {
  
      console.log('connected');
  
      // Do all the socket stuff here.
  
  })
  
  server.start(function(err) {
  
      if (err) {
          console.error(err);
          throw err;
      }
  
      console.log('Server started at %s', server.info.uri);
  
  });
  </code></pre>