smack to ejabberd

I tried to use Smack to connect a ejabberd server, but failed.

1. My hosts on ejabberd config:

{hosts, ["macbook.local", "public.macbook.local"]}.

2. My Smack client connection:

Connection connection = new XMPPConnection("macbook.local");
connection.connect();
connection.login(username, pwd);

It failed on connection.connect(), and the error msg say, "". Could not connect to macbook.local:5222.: remote-server-timeout(504) Could not connect to macbook.local:5222.
-- caused by: java.net.UnknownHostException: macbook.local

Any idea?
Thanks in advance.

Does this work for you? $

Does this work for you?

$ telnet macbook.local 5222
Trying 127.0.0.1...
Connected to macbook.local.
Escape character is '^]'.
testest
?xml version='1.0'? stream:stream xmlns='jabber:client'
 xmlns:stream='http://etherx.jabber.org/streams'
 id='1886875335' from='localhos...

If that fails, then "macbook.local" is an unknown host. Better use "localhost", or some DNS name that is known.

Syndicate content