JAVAMAIL - IMAP Connection Failure: "* BYE disconnecting"

From: Daniel Albisser (daniel.albisser_at_spam.swisscom.com)
Date: 02/23/04

  • Next message: Silvio Bierman: "Re: compiler optimization"
    Date: Mon, 23 Feb 2004 11:06:00 +0100
    
    

    Hi @ll,

    I using the Java Mail API to access a mail server over IMAP.

    Step-By-Step Program:
     1) Get all folders from the IMAP account
         - open connection to the store
         - accessing mail server and get folder structure
         - close connection to the store
     2) Get the emails for each account (loop)
         - open connection to the store
         - open current folder
         - accessing mail server and get emails of opened folder
         - close current folder
         - close connection to the store

    Problem:
     In the second step the program throws a MessagingException
     "* BYE Disonncetion". Some times by the first iteration othertimes
     on the seconde and so on.

    How I solved that problem (code snippet):
     ....
      int numOfTries = 0;
      int MAX_NUM_OF_TRIES = 10;
      boolean connected = false;
      while(!connected || numOfTries > MAX_NUM_OF_TRIES)
      {
          try
          {
              store.connect(
              storeInfo.getServerAddress(),
                              storeInfo.getUsername(),
                              storeInfo.getPassword());
              connected = true;
          }
          catch (MessagingException e)
          {
              System.out.println("Connection failed: Number of Try = " + numOfTries);
              System.out.println("Exception Message: " + e.getMessage());
            
              numOfTries++;
            
              try
              {
                  Thread.sleep(500);
              }
              catch (InterruptedException e1)
              {
              }
          }
      }
    ....

    With this code it works, but the mail client has to try connecting 4 times! That
    means it takes up to 2 seconds for accesing the system! I think this it is not really
    the best solution, it takes ~four times longer to establish a connection to the
    server!

    Questions:
     - Does somebody know that problem and how has he/she solved that?
     - Is there another way to solve it?
     - This problem lies on the serverside - Is that true?
     - Is this a familiar problem of IMAP mail servers?

    Thanks a lot for helping!
    Greetz,
    Dani

    -- 
    NOTE:
     To contact me directly remove "spam." from the email address.
    

  • Next message: Silvio Bierman: "Re: compiler optimization"

    Relevant Pages

    • JAVAMAIL - IMAP Connection Failure: "* BYE disconnecting"
      ... I using the Java Mail API to access a mail server over IMAP. ... Get all folders from the IMAP account ... Get the emails for each account ...
      (comp.lang.java.programmer)
    • JAVAMAIL - IMAP Connection Failure: "* BYE disconnecting"
      ... I using the Java Mail API to access a mail server over IMAP. ... Get all folders from the IMAP account ... Get the emails for each account ...
      (comp.lang.java.developer)
    • Re: Tricky mail (server) configuration
      ... I am searching for an IMAP mail server for a very special setup. ... No problem for UW-IMAP. ... Thunderbird keeps IMAP connections open all the time and keeps a local ... One thing left out, in case you also need a mail server, I use Exim ...
      (comp.mail.imap)
    • Re: send email
      ... > to act as a mail server for local and remote clients, ... while IMAP only transfers the message header. ... > In addition to the imap daemon, you also need to have sendmail running ...
      (alt.os.linux.redhat)
    • Re: Emails access to one account on two computers
      ... If your ISP offers IMAP mail server access, that is the way to go. ... >I posted recently about access to emails via OE for multiple Windows ...
      (microsoft.public.windows.inetexplorer.ie6_outlookexpress)