简体   繁体   English

如何在Intranet中建立socket.io连接

[英]How to make socket.io connection in intranet

I'm trying to build a node.js chat web-app. 我正在尝试构建一个node.js聊天网络应用程序。 Here is the code that I'm using . 这是我正在使用的代码 Running this app, only works on localhost. 运行此应用程序,仅适用于本地主机。

How do I to make it work on Intranet, please ? 请问如何使它在Intranet上运行?

EDIT : On Intranet, to test this. 编辑:在Intranet上进行测试。 I type on the web browser http://IPaddressHostChat:8080 . 我在网络浏览器上输入http://IPaddressHostChat:8080 The web browser gets the web page, but, the exchanged messages are not displayed among computers. Web浏览器获取网页,但是,交换的消息不会在计算机之间显示。

How to fix this please? 请问该如何解决?

Thanks a lot! 非常感谢!

The problem is most likely that you refer to a specific host and port in your client's code. 问题很可能是您在客户端代码中引用了特定的主机和端口。 Use just io.connect() dropping host and port in the html file. 仅使用io.connect()在html文件中删除主机和端口。 See the following for exactly the same issue: 404 on Socket.io connect 完全相同的问题,请参见以下内容: Socket.io connect上的404

First, you need to know your host IP address. 首先,您需要知道您的主机IP地址。 You can do that by opening cmd and type ipconfig 您可以通过打开cmd并键入ipconfig来做到这一点。

Then, you should be able to see your own IP address, usually is 192.168.1.** 然后,您应该能够看到自己的IP地址,通常是192.168.1。**。

Use that IP address for your socket connection. 使用该IP地址进行套接字连接。

Make sure your client is on the same intranet as yours. 确保您的客户端与您的客户端在同一个Intranet上。 You can check your client connection with your server connection by typing 您可以通过键入以下内容来检查客户端连接和服务器连接

ping <host ip address>

or if it doesnt give you a ping or request time out, you may check by typing this in cmd 或者,如果它不给您ping命令或请求超时,则可以通过在cmd中键入此命令进行检查

tracert <host ip address>

Using this command, you will be able to track which part is stopping your client from connecting to your server! 使用此命令,您将能够跟踪哪个部分阻止了客户端连接到服务器! Usually it might be due to some firewall settings! 通常这可能是由于某些防火墙设置所致!

I have no problem deploying my websocket using intranet! 我使用Intranet部署Websocket没问题!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM