从局域网访问ws套接字服务器


Accessing to the ws socket server from LAN

我正在尝试访问我的websocket服务器,它在我的计算机上运行Apache 2.4.9。这是配置。Apache监听来自8081端口上任何IP地址的所有连接。因此,我可以使用localhost:8081或我的静态IP 192.168.1.1:8081访问它。一切都很好,我可以打开php网页但是。

有一个php文件监听ws连接。它监听2012端口的连接。所以这就是问题所在,我可以使用localhost:2012连接到它,但不能使用我的静态IP地址如192.168.1.1:2012连接。

防火墙对从所有地址到2012和8081端口的传入tcp连接有规则。我试过完全禁用它。不工作。

在这种情况下我该怎么做?

通过不输入第二个参数,它只在本地主机(127.0.0.1)上侦听。

$webSock->listen(2012, '0.0.0.0'); 
   // Binding to 0.0.0.0 will bind to all interfaces and allow remotes to connect