Handling of server ping timeout: ServerPingListener

Issue #14 closed
Markus KARG created an issue

Currently PingManager frequently tries to ping server, but simply prints a stack trace when the ping fails. It is doubtful whether this makes pretty much sense: While the stack trace is visible to the end user of a calling application, that user cannot know what the stack trace means hence might "panic", on the other hand, the application would be able to deal with the problem (like disabling application functionality) but has no means to detect the problem.

Hence handling of server ping timeout should be given an improved handling: * No stack trace printed to not confuse end users. * Forwarding the server ping timeout to the calling application (i. e. new interface ServerPingListener). * Possibly changing the XmppSession state and any running Chats.

Comments (5)

  1. Christian Schudt repo owner

    Hm, actually the ping is only used here to tell the server "I'm still there, don't disconnect me". I've got reports that some servers do that after e.g. 60 minutes without traffic. If the ping fails it's either because a) the server does not support XEP-0199 (such servers don't exist I think) or b) we are disconnected. Nobody would care about a) because the ping still served its purpose (to put some traffic on the wire). And if b) happens the write to the Socket's outputstream should throw an IOException, which in turn informs the session about a disconnection.

    What do you think? Is it really needed? Maybe just don't log the stacktrace?

  2. Markus KARG reporter

    Christian, the "correct" solution depends on what you think that the target design of Babbler is: * You can omit logging of the exception and close the XmppSession, which in turn triggers a session listener. This mixes XEPs but is very simple to use for the application programmer. * You can omit logging of the exception and trigger a ServerPingListener. This separates XEPs but is rather complex to use by the application programmer.

    I would appreciate if you finally decide for a general design guideline in Babbler (separate XEPs to induce application programmer troubles, or mix XEPs and make their lives easier), just for any, so we can finally get a terminal fix for this bug. :-)

  3. Log in to comment