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

时间:2022-01-31 15:47:06

Chat server is listening to the port, below snippet is from console log.

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

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

When trying to connect through browser: eg: "localhost:4000", connection is refused(Error code: ERR_CONNECTION_REFUSED)

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

Can some one help how to fix this issue?.

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

Note: I have tried listening on "127.0.0.1" and given original IP address in the network.

注意:我已尝试收听“127.0.0.1”并在网络中提供原始IP地址。

1 个解决方案

#1


2  

You can access the server using the URL that cloud9 provides for that specific server/project.

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

Use process.env.PORT as the port and process.env.IP as the host for you application and access your app using your project name - username. Should be something like https://mynodetest-someone.c9.io.

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

From the c9 page:

从c9页面:

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

重要提示:使用process.env.PORT作为端口,并使用process.env.IP作为脚本中的主机!

#1


2  

You can access the server using the URL that cloud9 provides for that specific server/project.

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

Use process.env.PORT as the port and process.env.IP as the host for you application and access your app using your project name - username. Should be something like https://mynodetest-someone.c9.io.

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

From the c9 page:

从c9页面:

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

重要提示:使用process.env.PORT作为端口,并使用process.env.IP作为脚本中的主机!