Nodejs writes the backend, native ip is normal, other ip access prompts upgrade required

var WebSocketServer = require("D:/0.ProgramFiles/2.Devel/4.NodeJs/node_modules/ws").Server;
var wss = new WebSocketServer({port: 8888});
var userList = [];

wss.on("connection", function (ws,req) {
    console.log("",req.connection.remoteAddress);
    // console.log(getUUID());

    ws.on("message", function (message) {
        console.log(":" + message);
        wss.clients.forEach(function each(client) {
            client.send(message);
        });
    });

    ws.on("close", function (message) {
        console.log("",req.connection.remoteAddress);
    });

});

as in the above code, the browser access on your computer is normal, and other ip access pages on the same local area network only display "upgrade required"

.

can you tell me how to solve the problem? Thank you

(after inviting several bosses, I thought it might disturb you. If there is any disturbance, I am really sorry ~)

Mar.19,2021

https://stackoverflow.com/que.
you need to create a http server

var express = require('express')
var expressWs = require('express-ws')

var app = express()
expressWs(app)

app.ws('/echo', (ws, req) => {

    ws.on('connection', function (connection) {
        //...
    })

    ws.on('close', function () {
        //...
    })
})

app.use(express.static('public'))
app.listen(3000, function () {
    console.log('Example app listening on port 3000!')
})
Menu