在“cloud9-ide”上运行的Node.js聊天服务器正在侦听,但无法使用客户端进行连接

聊天服务器正在监听端口,下面的代码片段来自控制台日志。

Your code is running at https://mynodetest-someone.c9.io. Important: use process.env.PORT as the port and process.env.IP as the host in your scripts! debugger listening on port 15454 info - socket.io started Chat server listening at 0.0.0.0:4000 

当试图通过浏览器连接:例如:“localhost:4000”,连接被拒绝( 错误代码:ERR_CONNECTION_REFUSED)

有人可以帮助解决这个问题吗?

注意:我试过在“127.0.0.1”上进行监听,并给出了networking中的原始IP地址。

您可以使用cloud9为特定服务器/项目提供的URL来访问服务器。

使用process.env.PORT作为端口, process.env.IP作为您的应用程序的主机,并使用您的项目名称 – 用户名访问您的应用程序。 应该是像https://mynodetest-someone.c9.io

从c9页面:

Important: use process.env.PORT as the port and process.env.IP as the host in your scripts!