JAVAMAIL - IMAP Connection Failure: "* BYE disconnecting"

Discussion in 'Java' started by Daniel Albisser, Feb 23, 2004.

  1. 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.
    Daniel Albisser, Feb 23, 2004
    #1
    1. Advertising

  2. Daniel Albisser

    GaryM Guest

    "Daniel Albisser" <> wrote in news:1077530791.793851@ftpgate:

    > 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


    A couple of pointers that might help.

    First put Javamail in debug mode:

    props.put("mail.debug", "true");

    where props is your Session props. This should
    provide a level of detail in the connection process
    that might show you how far you are getting.

    Second, review the timeouts per the doc here.
    Most are infinite, but a few are not:

    http://java.sun.com/products/javamail/1.3/docs/javadocs/com/sun/mail/imap/package-summary.html

    Lastly repost your question to Sun's Javamail Forum here,
    where there are a lot of highly experienced users of this API:

    http://forum.java.sun.com/forum.jsp?forum=43

    HTH,

    Gary
    GaryM, Feb 23, 2004
    #2
    1. Advertising

  3. Thx - I'm going to "play around" with this properties!

    Greetz

    "GaryM" <> wrote in message news:Xns94989A1AE77R3344324357788499939@216.168.3.44...
    > "Daniel Albisser" <> wrote in news:1077530791.793851@ftpgate:
    >
    > > 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

    >
    > A couple of pointers that might help.
    >
    > First put Javamail in debug mode:
    >
    > props.put("mail.debug", "true");
    >
    > where props is your Session props. This should
    > provide a level of detail in the connection process
    > that might show you how far you are getting.
    >
    > Second, review the timeouts per the doc here.
    > Most are infinite, but a few are not:
    >
    > http://java.sun.com/products/javamail/1.3/docs/javadocs/com/sun/mail/imap/package-summary.html
    >
    > Lastly repost your question to Sun's Javamail Forum here,
    > where there are a lot of highly experienced users of this API:
    >
    > http://forum.java.sun.com/forum.jsp?forum=43
    >
    > HTH,
    >
    > Gary
    >
    Daniel Albisser, Feb 24, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Henrik Ormåsen

    Curier-IMAP and imap.create()

    Henrik Ormåsen, Aug 19, 2006, in forum: Ruby
    Replies:
    0
    Views:
    174
    Henrik Ormåsen
    Aug 19, 2006
  2. Jon Fi
    Replies:
    4
    Views:
    520
    Kashia Buch
    Oct 21, 2006
  3. jasonnaylor
    Replies:
    1
    Views:
    247
    jasonnaylor
    Apr 16, 2008
  4. Adam Akhtar
    Replies:
    1
    Views:
    172
    Eric Hodel
    Dec 15, 2008
  5. Abhishiv Saxena

    Support for IMAP IDLE in net/imap

    Abhishiv Saxena, Jul 3, 2009, in forum: Ruby
    Replies:
    4
    Views:
    190
    Eric Hodel
    Jul 4, 2009
Loading...

Share This Page