Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ecf-dev] XMPP

Hi Ali,

Ali Naddaf schrieb:
> Thank you Scott. I have made some progress there and hopefully soon will
> have a complete working example that I can share in case you would be
> interested in posting that. I am sure I will have some questions on the
> way but one that I ran into is the following: if I make a connection
> (using container.connect(...)), and if I lose connectivity (due to
> network) and gain internet connectivity again, I will not be reconnected
> automatically. If I were to use the smack libraries directly to connect
> to a jabber server, it would reconnect automatically so is there an
> option there that I can enable this feature?

I ran into the same issue in a project I worked on last year. The
reconnect feature of the Smack library theoretically works, but ECF
internally handles the disconnected event by explicitly closing the
connection. The way we worked around this problem was by simply
disabling the forwarding of the event in the ECFConnection. There is an
internal ConectionListener in ECFConnection which listens on the Smack
connection. In that listener, simply disable the call to
handleConnectionClosed(e) in connectionClosedOnError:

private final ConnectionListener connectionListener = new
ConnectionListener() {
  public void connectionClosed() {
    handleConnectionClosed(new IOException("Connection reset by peer"));
  }

  public void connectionClosedOnError(Exception e) {
    // Handling disabled to make automatic reconnection by Smack 3.1
    // work.

    // handleConnectionClosed(e);

Obviously, that is not a clean solution, but it did the job for our use
case. I guess it would have some side effects if one tries to use the
connection while it is interrupted. Unfortunately I did not have the
time to find a better solution, and I am now no longer working on that
project.

Anyway, I hope this will help you to find a solution for your case.

Cheers
Jörg

-- 
Dipl.-Wirt.Inf. Jörg Rathlev        rathlev@xxxxxxxxxxxxxxxxxxxxxxxxx
Zentrum für Architektur und                    Fon: +49-40-42883-2305
Gestaltung von IT-Systemen (AGIS)              Fax: +49-40-42883-2303
MIN-Fakultät, Department Informatik            Sec: +49-40-42883-2413
Universität Hamburg    http://agis-www.informatik.uni-hamburg.de/swt/


Back to the top