Hic cup
Added almost 3 years ago


 Exception in worker Read timed out
    at Method)
    at Source)
    at Source)
    at Source)
    at Source)
    at Source)

Method keepalive() in just send "new byte[] { 32 }" to server,but the server response nothing.

Should I send ping to keep alive instead of "new byte[] { 32 }" ?


Replies (6)


Added by Wojciech Kapcia TigaseTeam almost 3 years ago

This is whitespace ping and it's described in RFC1620 - Dead Connection No, server don't have to respond to it. If you require more resilience you can utilize XEP-0199: XMPP Ping which is also supported in JaXMPP and Tigase server.


Added by Hic cup almost 3 years ago

thinks for reply!

"Read timed out" Exception occurred if only use "jaxmpp.keepalive()".

I guess it caused by noting response.... then socket timeout.

should i ignore this ?

Added by Wojciech Kapcia TigaseTeam almost 3 years ago

What are you trying to do exactly???

This is simple keepalive packet to keep the connection open, it doesn't require the response and stacktrace provided by you doesn't match any current branch from Jaxmpp library.

In addition - jaxmpp.keepalive() will be called periodically when needed and there's no need to call it manually.

Added by Hic cup almost 3 years ago

My test file:

public static void main(String[] args) throws JaxmppException, InterruptedException {
        final Jaxmpp jaxmpp = new Jaxmpp();

        jaxmpp.getProperties().setUserProperty(SocketConnector.SERVER_HOST, "");
        jaxmpp.getProperties().setUserProperty(SessionObject.USER_BARE_JID, BareJID.bareJIDInstance(""));
        jaxmpp.getProperties().setUserProperty(SessionObject.PASSWORD, "1");




        PresenceModule presence=jaxmpp.getModulesManager().getModule(PresenceModule.class);

        MessageModule msgmodule = jaxmpp.getModulesManager().register(new MessageModule());

        jaxmpp.getEventBus().addHandler(MessageReceivedEvent.class, msgmodule, new MessageReceivedHandler() {

            public void onMessageReceived(SessionObject sessionObject, Chat chat, Message stanza) {
                try {
                    System.out.println("-------MessageReceived-------" + stanza.getBody());
                } catch (XMLException e) {

        Thread.sleep(10 * 60 * 1000);


Just now I find the "jaxmpp.getConnectionConfiguration().setDisableTLS(true);" cause the Exception.

It works well since Comment this line, I will check the detail tomorrow.

think you very much!

Added by Wojciech Kapcia TigaseTeam almost 3 years ago

Bottomline - keepalive is enabled by default and you can disable it with Connector option: @Connector.DISABLE_KEEPALIVE_KEY@:

jaxmpp.getProperties().setUserProperty( SocketConnector.DISABLE_KEEPALIVE_KEY, Boolean.TRUE );

Executing it manually is not recommended. Also - it's possible connection is not yet fully established and checking if user is connected (@jaxmpp.isConnecte()@) is a good idea.


Added by Hic cup almost 3 years ago

i see, thinks!