为什么节点 js 套接字在将端口更改为 https 时不起作用? [英] why node js socket not working when change port to https?

查看:66
本文介绍了为什么节点 js 套接字在将端口更改为 https 时不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常在 app.js 中,我在端口 3000 上使用此代码,它运行良好(在 my-domain.com:3000 上).

Normally in app.js i use this code on port 3000 it's work good (on my-domain.com:3000).

.

http.listen(3000, function(){
    console.log('start server on port :3000');
});

然后我想在 https 上使用,所以我将 app.js 更改为

then i want to use on https, so i change app.js to

http.listen(443, function(){
    console.log('start server on port :443');
});

运行 node app.js 时,显示错误

events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE :::443
    at Object.exports._errnoException (util.js:1012:11)
    at exports._exceptionWithHostPort (util.js:1035:20)
    at Server._listen2 (net.js:1252:14)
    at listen (net.js:1288:10)
    at Server.listen (net.js:1384:5)
    at Object.<anonymous> (/home/admin/web/my-domain.com/public_html/app.js:28:6)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)

通常我必须访问 my-domain.com:3000 进行用户聊天.所以我想知道如何访问 https://www.my-domain.com 进行用户聊天?

Normally i have to access to my-domain.com:3000 for user chat. So i want to know how can i access to https://www.my-domain.com for user chat ?

推荐答案

您收到以下错误消息:

Error: listen EADDRINUSE :::443
[...]

此消息表示端口 443 当前正被某个进程使用.

This message means that the port 443 is currently in use by some process.

您可以通过执行用于网络检查的众多工具之一(例如 netstat for Windows、lsofLinux 上的 netstat).

You can check which process is actually using the said port by executing one of the many tools for network checking (such as netstat for Windows, lsof or netstat on Linux).

请参阅这些工具的手册,以根据您的操作系统获得正确的结果.

Refer to the manual for those tools to achieve the correct result, based upon your operating system.

这篇关于为什么节点 js 套接字在将端口更改为 https 时不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆