PHP 无法连接到端口 5222 上的本地主机 XMPP 服务器

发布于 2024-08-28 07:04:23 字数 419 浏览 2 评论 0原文

我已经在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

以为你会在 2024-09-04 07:04:23

selinux 需要关闭,或者允许 apache 与 xmpp 对话

selinux needs to be off, or allow apache to talk to xmpp

衣神在巴黎 2024-09-04 07:04:23

许多服务器默认情况下不侦听环回设备,或者仅侦听 ::1 或 127.0.0.1 并让 localhost 指向另一个。通过执行以下操作进行检查:

% netstat -an | grep 5222

并检查 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:

% netstat -an | grep 5222

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.

睫毛上残留的泪 2024-09-04 07:04:23

有时您只需查看线路即可准确了解发生了什么情况。 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文