Kakey
Kakey

Reputation: 4024

XMPP (smack) in android gives "java.lang.IllegalStateException: Not connected to server."

I have created simple chat application using smack api.i can able to chat well.but sometimes the connection to the server is disconnected and following error is thrown.

java.lang.IllegalStateException: Not connected to server.

how to reconnect to server again?

thanks.

Upvotes: 2

Views: 3415

Answers (2)

Hari Gudigundla
Hari Gudigundla

Reputation: 822

java.lang.IllegalStateException: Not connected to server - is thrown in multiple senarios. One such case is while trying to login to an xmpp server as follow:

......

ConnectionConfiguration connConfig = new ConnectionConfiguration(host, port, service);

            XMPPConnection connection = new XMPPConnection(connConfig);
                connection.connect();
                connection.login(username, password);

......

Check out smack javadoc here
Reason as given in above link: if not connected to the server, or already logged in to the server

If you are trying to connect to a local xmpp server from an android client, this link could be very helpful

Upvotes: 1

Kakey
Kakey

Reputation: 4024

This error is due to same user already logged in another apps.

Upvotes: 2

Related Questions