How can I do port binding for Express, Socket.io, WebSocket?

Viewed 148

Currently, Express server using HTTPS communication and Socket.io are using the same port 443. However, it's necessary to apply the third-party project to the web server, so it's necessary to use the WebSocket package together.

I found the article below to find a way to use the same port 443 for Express, Socket.io, and WebSocket respectively, but I don't know if this is correct.

Reference article URL : Go to page

app.js

const express = require('express');
... Some register middleware

module.exports = app;

bin/www

const app = require('../app');
const https = require('https');
...
const server = https.createServer(options, app);
const io = require('socket.io)(server);

io.on('connection', (socket) => {
    ....
});

server.listen(443, '0.0.0.0');
0 Answers
Related