Why node.js requires an upgrade while trying to run an application on the localhost?

前端 未结 4 739
梦毁少年i
梦毁少年i 2020-12-20 11:53

When I try to run my node.js application on a localhost server, it does not run and demands a required upgrade. I have tried to run the code but I get the following error:

4条回答
  •  旧巷少年郎
    2020-12-20 12:57

    The issue is that your web socket server is running on port 80, so when you open the html template using your browser, you are actually opening the web socket server. This is because web pages opening in the browser default to using port 80.

    To fix this set your web socket server's port to something else like 3000.

    ws = new WebSocketServer({port: 3000})

    Then when you open the page in the browser it will open the actual html page instead of the web socket server.

提交回复
热议问题