0
votes

I have a strange problem. I am trying to create a Xmpp client using smack api library 4.2.4 hosted on a servlet in apache tomcat.

I can able to send & receive to messages (via Chat Listener events) , whereas i am not getting any MUC invitations nor packet listener events for MUC alone.

i had checked in debug logs, events not appeared there as well. Where as if i try the same code in a Java Console App(no changes just a console main entry & Debug) , i am getting all those events.

Any idea on how to make smack work on servlets?

Thanks in advance...

Note : I'm Using single instance of connection. I have no issues on chat send or response. Facing issues onky on MUC invitations....

1

1 Answers

0
votes

Fixed finally... Implemented connection listener and reconnected on connection drop. Now all looks good.

connection.addConnectionListener(new ConnectionListener() {

                @Override
                public void reconnectionSuccessful() {
                    Log.i("","Successfully reconnected to the XMPP server.");

                }

                @Override
                public void reconnectionFailed(Exception arg0) {
                    Log.i("","Failed to reconnect to the XMPP server.");
                }

                @Override
                public void reconnectingIn(int seconds) {
                    Log.i("","Reconnecting in " + seconds + " seconds.");
                }

                @Override
                public void connectionClosedOnError(Exception arg0) {
                    Log.i("","Connection to XMPP server was lost.");

PerformReConnect(); }

                @Override
                public void connectionClosed() {
                    Log.i("","XMPP connection was closed.");

                }
            });