asmack connects to ejabberd server

Hi,
I have similar problems, but not found any solution..

asmack connects to ejabberd server

http://www.ejabberd.im/node/4648
http://www.ejabberd.im/node/3643
http://www.ejabberd.im/node/4792

this is my details..
I have setup my own ejabberd server,
and I can successfully connected and logon using Psi+ client.

and when i try to write my own java asmack client, but I can't connect/login.
http://code.google.com/p/asmack/


do i need to update any setting in my ejabberd server?
or is that asmack libray problem?

Can any one please give me a hint
or any direction is much appreciated.

how to connect and login..?

Here is my java code:

ConnectionConfiguration cc = new ConnectionConfiguration("my_ejabberd_server_domain_name", 5222);
cc.setDebuggerEnabled(true);
con = new XMPPConnection(cc);

System.setProperty("smack.debugEnabled", "true");
XMPPConnection.DEBUG_ENABLED = true;
Log.e(TAG, "con= " + con);

try {
SASLAuthentication.supportSASLMechanism("PLAIN", 0);
con.connect();
con.login("myusername", "password");
// See if you are authenticated
Log.d(TAG, "isAuthenticated="+con.isAuthenticated());
    
} catch (XMPPException xe) {
xe.printStackTrace();
return;
}

Here is the log

ERROR/Main(887): con= org.jivesoftware.smack.XMPPConnection@43b94d50
INFO/global(887): Default buffer size used in BufferedWriter constructor. It would be better to be explicit if an 8k-char buffer is required.
DEBUG/SMACK(887): 07:45:12 PM SENT (1136217424): <stream:stream to="test" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0">
DEBUG/SMACK(887): 07:45:12 PM RCV  (1136217424): <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='3424231402' from='irvascloud' xml:lang='en'><stream:error><host-unknown xmlns='urn:ietf:params:xml:ns:xmpp-streams'/></stream:error></stream:stream>

DEBUG/SMACK(887): 07:45:12 PM SENT (1136217424): <iq id="CQcRr-0" type="get"><query xmlns="jabber:iq:auth"><username>myusername</username></query></iq>
DEBUG/SMACK(887): 07:45:12 PM SENT (1136217424): <presence id="CQcRr-1" type="unavailable"></presence>
DEBUG/SMACK(887): 07:45:12 PM SENT (1136217424): </stream:stream>

WARN/System.err(887): stream:error (host-unknown)
WARN/System.err(887):     at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:261)
WARN/System.err(887):     at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44)
WARN/System.err(887):     at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:71)
WARN/ActivityManager(51): Launch timeout has expired, giving up wake lock!
DEBUG/dalvikvm(216): GC freed 43 objects / 2096 bytes in 260ms
DEBUG/dalvikvm(101): GC freed 4131 objects / 196408 bytes in 403ms

please, any comments or suggestions are greatly appreciated..
:)

This is your client code: new

This is your client code:
new ConnectionConfiguration("my_ejabberd_server_domain_name", 5222);

So, you should configure this in ejabberd.cfg
{hosts, ["my_ejabberd_server_domain_name"]}.

But when your client connects to ejabberd, it attempts to login to a different vhost:
to="test" xmlns="jabber:client"

ejabberd complains that it doesn't serve that vhost:
... from='irvascloud' xml:lang='en'>

thanks, it works. i can login

thanks, it works. i can login now.

ConnectionConfiguration cc = new ConnectionConfiguration(
"my_ejabberd_server_domain_name", 5222, "irvascloud");

thanks for the help @badlop.

:)

hello badlop, " ejabberd

hello badlop,
"
ejabberd complains that it doesn't serve that vhost:
... from='irvascloud' xml:lang='en'>"

what does it mean

I am also getting same eroor while trying to log in on ejabbered 2.1.11 server install on my local machine
what would be possible resone of it

My code is as below

private class DownloadWebPageTask extends AsyncTask {

@Override
protected Void doInBackground(String... params) {
int portInt = 5222;

// Create a connection
ConnectionConfiguration connConfig =
new ConnectionConfiguration("192.168.0.104", portInt,"localhost");
connConfig.setSASLAuthenticationEnabled(true);
connConfig.setCompressionEnabled(true);
connConfig.setSecurityMode(SecurityMode.enabled);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
connConfig.setTruststoreType("AndroidCAStore");
connConfig.setTruststorePassword(null);
connConfig.setTruststorePath(null);
Log.i("XMPPClient", "[XmppConnectionTask] Build Icecream");

} else {
connConfig.setTruststoreType("BKS");
String path = System.getProperty("javax.net.ssl.trustStore");
if (path == null)
path = System.getProperty("java.home") + File.separator + "etc"
+ File.separator + "security" + File.separator
+ "cacerts.bks";
connConfig.setTruststorePath(path);
Log.i("XMPPClient", "[XmppConnectionTask] Build less than Icecream ");

}
connConfig.setDebuggerEnabled(true);
XMPPConnection.DEBUG_ENABLED = true;
XMPPConnection connection = new XMPPConnection(connConfig);

try {
connection.connect();
Log.i("XMPPClient", "[SettingsDialog] Connected to " + connection.getHost());
// publishProgress("Connected to host " + HOST);
} catch (XMPPException ex) {
Log.e("XMPPClient", "[SettingsDialog] Failed to connect to " + connection.getHost());
Log.e("XMPPClient", ex.toString());
//publishProgress("Failed to connect to " + HOST);
// xmppClient.setConnection(null);
}

try {
connection.login("xyzw@localhost","admin");
Log.i("androxmpp", "Logged in as" + connection.getUser());
} catch(Exception ex){

Log.i("androxmpp", "loginfails ");
ex.printStackTrace();
}
return null;

}
}

and smack debug log and android log is as below

07-12 15:59:31.735: I/XMPPClient(7363): [XmppConnectionTask] Build Icecream
07-12 15:59:31.825: D/SMACK(7363): 03:59:31 pm SENT (1100387832):
07-12 15:59:32.035: D/SMACK(7363): 03:59:32 pm RCV (1100387832): <?xml version='1.0'?>
07-12 15:59:32.045: I/XMPPClient(7363): [SettingsDialog] Connected to 192.168.0.104
07-12 15:59:32.065: D/SMACK(7363): 03:59:32 pm SENT (1100387832):
07-12 15:59:32.345: I/androxmpp(7363): loginfails
07-12 15:59:32.345: W/System.err(7363): java.lang.IllegalStateException: Not connected to server.
07-12 15:59:32.345: W/System.err(7363): at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:229)
07-12 15:59:32.345: W/System.err(7363): at org.jivesoftware.smack.Connection.login(Connection.java:371)
07-12 15:59:32.345: W/System.err(7363): at com.example.androxmpp.MainActivity$DownloadWebPageTask.doInBackground(MainActivity.java:89)
07-12 15:59:32.345: W/System.err(7363): at com.example.androxmpp.MainActivity$DownloadWebPageTask.doInBackground(MainActivity.java:1)
07-12 15:59:32.345: W/System.err(7363): at android.os.AsyncTask$2.call(AsyncTask.java:287)
07-12 15:59:32.345: W/System.err(7363): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
07-12 15:59:32.345: W/System.err(7363): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
07-12 15:59:32.355: W/System.err(7363): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
07-12 15:59:32.355: W/System.err(7363): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
07-12 15:59:32.355: W/System.err(7363): at java.lang.Thread.run(Thread.java:841)
07-12 16:03:43.073: W/InputMethodManager(7363): [FXN.ASD] InputBindResult is null

Hope you will replay soon
thanks!!!!

Syndicate content