Project

General

Profile

Jaxmpp3 reconnect to tigase server

shir Hu
Added over 3 years ago

Hi, buddies,

I use socket connection type and try to add StreamTerminatedHandler to listen if connect terminate as below.

    jaxmpp.getEventBus().addHandler(StreamTerminatedHandler.StreamTerminatedEvent.class, new StreamTerminatedHandler(){

                @Override
                public void onStreamTerminated(SessionObject sessionObject) throws JaxmppException {
                    // TODO Auto-generated method stub
                    jaxmpp.login(true);
                }

    });

Then shutdown tigase server and found that jaxmpp begin to open new socket connection every seconds, After tigase server restart, Exceptions appears on java console one after another lasted 2 minutes. Can you tell me if something is wrong call re-login this way? Thank you.


Replies (1)

(1)
Avatar?id=6098&size=32x32

Added by Bartosz Małkowski TigaseTeam over 3 years ago

To autoreconnect try to use something like this:

jaxmpp.getEventBus().addHandler(Connector.StateChangedHandler.StateChangedEvent.class,
        new Connector.StateChangedHandler() {
            @Override
            public void onStateChanged(SessionObject sessionObject, Connector.State oldState, Connector.State newState)
                    throws JaxmppException {
                if (newState == Connector.State.disconnected) {
                    jaxmpp.login(true);
                }
            }
        });

    (1-1/1)