0
votes

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!

3
Did you 1) check out what's the error message? 2) check if the server is running i.e. on localhost?mauris
Yep, the error message simply says the connection timed out: "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond." And as I said above, the server is running and can be connected to from a standard IM client.Ben Werdmuller

3 Answers

1
votes

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

1
votes

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.

0
votes

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