Handle Exchange connection loss
Brought to you by:
mguessan
My employer's Exchange server is only reachable when my computer is connected to the company network. So often DavMail cannot connect to Exchange. However, my Thunderbird is not aware that the actual server is not reachable, since it is able to set up connections to DavMail (on localhost). The result is that Thunderbird keep asking me for credentials. Would it be a possibility to have DavMail deny access to it's server ports when Exchange cannot be reached? Or can a suitable imap/pop3/smtp/etc error state be returned to Thunderbird?
Hmm, the situation seems to be a bit more complex. Access to our OWA from outside the company network is redirected to a VPN log-in site, which is recognized by DavMail as a log-in form:
2012-01-23 11:47:11,522 DEBUG [ImapConnection-55653] davmail - executeFollowRedirects(https://webmail.cargotec.com/owa/)
2012-01-23 11:47:11,967 DEBUG [ImapConnection-55653] davmail - executeFollowRedirects: http://kiosk.cargotec.com/ redirectCount:1
2012-01-23 11:47:12,112 DEBUG [ImapConnection-55653] davmail - executeFollowRedirects: https://kiosk.cargotec.com/ redirectCount:2
2012-01-23 11:47:12,172 DEBUG [ImapConnection-55653] davmail - executeFollowRedirects: https://kiosk.cargotec.com/dana-na/auth/url_default/welcome.cgi redirectCount:3
2012-01-23 11:47:12,604 DEBUG [ImapConnection-55653] davmail.exchange.ExchangeSession - Form based authentication detected
2012-01-23 11:47:12,605 DEBUG [ImapConnection-55653] davmail - executeFollowRedirects(https://kiosk.cargotec.com/dana-na/auth/url_default/login.cgi)
2012-01-23 11:47:15,615 DEBUG [ImapConnection-55653] davmail - executeFollowRedirects: https://kiosk.cargotec.com/dana-na/auth/url_default/welcome.cgi?p=failed&auth=1 redirectCount:1
2012-01-23 11:47:15,749 DEBUG [ImapConnection-55653] davmail - executeFollowRedirects(https://kiosk.cargotec.com/dana-na/auth/url_default/login.cgi)
2012-01-23 11:47:16,121 DEBUG [ImapConnection-55653] davmail - executeFollowRedirects: https://kiosk.cargotec.com/dana-na/auth/url_default/welcome.cgi?p=more-cred&id=state_2e43341a02667372cddb4522249d6f91 redirectCount:1
2012-01-23 11:47:16,198 ERROR [ImapConnection-55653] davmail.exchange.ExchangeSession - Authentication failed: invalid user or password
2012-01-23 11:47:16,198 ERROR [ImapConnection-55653] davmail - Authentication failed: invalid user or password
davmail.exception.DavMailAuthenticationException: Authentication failed: invalid user or password
at davmail.exchange.ExchangeSession.throwAuthenticationFailed(ExchangeSession.java:625)
at davmail.exchange.ExchangeSession.postLogonMethod(ExchangeSession.java:511)
at davmail.exchange.ews.EwsExchangeSession.formLogin(EwsExchangeSession.java:152)
at davmail.exchange.ExchangeSession.<init>(ExchangeSession.java:192)
at davmail.exchange.ews.EwsExchangeSession.<init>(EwsExchangeSession.java:141)
at davmail.exchange.ExchangeSessionFactory.getInstance(ExchangeSessionFactory.java:143)
at davmail.exchange.ExchangeSessionFactory.getInstance(ExchangeSessionFactory.java:94)
at davmail.imap.ImapConnection.run(ImapConnection.java:135)
2012-01-23 11:47:16,198 DEBUG [ImapConnection-55653] davmail - > 1 NO LOGIN failed
2012-01-23 11:47:16,201 DEBUG [ImapConnection-55653] davmail - < LOGIN ********
So it seems my feature request is invalid (assuming 'no connection' is already handled properly). But the VPN log-in site should somehow not be used for a 'normal' OWA log-in. Do you have any suggestions for that?
By adding an entry for 'kiosk.cargotec.com' with a non-existing IP address to /etc/hosts, the redirection fails.DavMail then still returns 'login failed':
2012-01-23 19:49:09,419 DEBUG [ImapConnection-57742] davmail - executeFollowRedirects(https://webmail.cargotec.com/owa/)
2012-01-23 19:49:09,850 DEBUG [ImapConnection-57742] davmail - executeFollowRedirects: http://kiosk.cargotec.com/ redirectCount:1
2012-01-23 19:49:19,853 ERROR [ImapConnection-57742] davmail.exchange.ExchangeSession - Exchange login exception: The host did not accept the connection within timeout of 10000 ms
2012-01-23 19:49:19,853 ERROR [ImapConnection-57742] davmail - Exchange login exception: The host did not accept the connection within timeout of 10000 ms
davmail.exception.DavMailException: Exchange login exception: The host did not accept the connection within timeout of 10000 ms
at davmail.exchange.ExchangeSession.<init>(ExchangeSession.java:214)
at davmail.exchange.ews.EwsExchangeSession.<init>(EwsExchangeSession.java:141)
at davmail.exchange.ExchangeSessionFactory.getInstance(ExchangeSessionFactory.java:143)
at davmail.exchange.ExchangeSessionFactory.getInstance(ExchangeSessionFactory.java:94)
at davmail.imap.ImapConnection.run(ImapConnection.java:135)
2012-01-23 19:49:19,853 DEBUG [ImapConnection-57742] davmail - > 5 NO LOGIN failed
2012-01-23 19:49:19,856 DEBUG [ImapConnection-57742] davmail - < LOGIN ********
2012-01-23 19:49:30,437 WARN [ImapConnection-57742] davmail.http.DavGatewayHttpClientFacade - The host did not accept the connection within timeout of 10000 ms
Thunderbird now shows a dialog telling that the connection failed, with a question to re-enter the password.
By adding an entry for 'webmail.cargotec.com' with a non-existing IP address to /etc/hosts, DavMail cannot make any initial connection and does not return a failure to Thunderbird. Thunderbird now times out as well, which is probably the desired behavior.
In my opinion, the situation where no connection can be made to the redirected server ('kiosk.cargotec.com') should be handled in the same way as when no connection can be made initially ('webmail.cargotec.com'). However, there might be situations where other (the current) behavior is desired.
I already tried to make sure server down answer is different from invalid credentials.
Your case seem special (first connection succeeds by server unavailable.