PHP 无法连接到端口 5222 上的本地主机 XMPP 服务器
我已经在 Windows 机器上本地安装了 ejabberd,其中还安装了 Apache、PHP 和 MySQL。我还确认使用 Digsby 效果很好,并且通过创建一些用户、发送一些消息等进行了一些尝试。一切都很好。
但是,PHP 无法使用stream_socket_client 打开端口5222 的流。即使在最简单的级别:
stream_socket_client("tcp://localhost:5222", $errno, $errstr, 30, STREAM_CLIENT_CONNECT);
返回超时错误。不过,再一次,使用 IM 客户端连接到端口 5222 上的本地主机可以正常工作。 (使用stream_socket_client在端口80上打开到本地主机的简单连接也可以。)
有什么想法吗?我被困住了!
I've set up an ejabberd install locally on my Windows box, where I also have Apache, PHP and MySQL. I've also confirmed that it works great using Digsby, and have kicked the tires a bit by creating some users, sending some messages, etc. All good.
However, PHP can't open a stream using stream_socket_client to port 5222. Even at its simplest level:
stream_socket_client("tcp://localhost:5222", $errno, $errstr, 30, STREAM_CLIENT_CONNECT);
Returns a timeout error. However, again, connecting with an IM client to localhost on port 5222 works fine. (Using stream_socket_client to open a simple connection to localhost on port 80 also works.)
Any ideas? I'm stuck!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
selinux 需要关闭,或者允许 apache 与 xmpp 对话
selinux needs to be off, or allow apache to talk to xmpp
许多服务器默认情况下不侦听环回设备,或者仅侦听 ::1 或 127.0.0.1 并让 localhost 指向另一个。通过执行以下操作进行检查:
并检查 LISTEN 行的输出,该行显示服务器正在侦听的位置。
最后,尝试明确使用您的盒子的 IP 地址作为连接主机名。
Many servers don't listen on the loopback device by default, or only listen on ::1 or 127.0.0.1 and have localhost pointing to the other. Check by doing:
and checking the output for a LISTEN line that shows where your server is listening.
Finally, try using the IP address of your box explicitly as the connection hostname.
有时您只需查看线路即可准确了解发生了什么情况。 Windump(tcpdump)在这些情况下, 是你的朋友。
Sometimes you just need to peek on the line to see exactly what is going on. Windump(tcpdump) is your friend in these cases.