开发者

PHP can't connect to localhost XMPP server on port 5222

开发者 https://www.devze.com 2022-12-25 23:33 出处:网络
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

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!


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


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.


Sometimes you just need to peek on the line to see exactly what is going on. Windump(tcpdump) is your friend in these cases.

0

精彩评论

暂无评论...
验证码 换一张
取 消