title: How can I do port binding for Express, Socket.io, WebSocket?
body: <p>Currently, <code>Express</code> server using <code>HTTPS</code> communication and <code>Socket.io</code> are using the same port <code>443</code>. However, it's necessary to apply the third-party project to the web server, so it's necessary to use the <code>WebSocket</code> package together.</p>
  <p>I found the article below to find a way to use the same port <code>443</code> for <code>Express</code>, <code>Socket.io</code>, and <code>WebSocket</code> respectively, but I don't know if this is correct.</p>
  <blockquote>
  <p>Reference article URL : <a href="https://gir.me.uk/posts/socket.io-and-ws-server-on-the-same-port.html" rel="nofollow noreferrer">Go to page</a></p>
  </blockquote>
  <p><strong>app.js</strong></p>
  <pre><code>const express = require('express');
  ... Some register middleware
  
  module.exports = app;
  </code></pre>
  <p><strong>bin/www</strong></p>
  <pre><code>const app = require('../app');
  const https = require('https');
  ...
  const server = https.createServer(options, app);
  const io = require('socket.io)(server);
  
  io.on('connection', (socket) =&gt; {
      ....
  });
  
  server.listen(443, '0.0.0.0');
  </code></pre>