5 Replies Latest reply: Aug 17, 2012 7:13 AM by 955077 RSS

    EOF on socket when opening pop3 inbox

    955077
      I have a Java program that reads a pop3 inbox and sends appropriate response emails. The program was working fine but something somewhere changed and now I get the following Exception:
      Exception in thread "main" javax.mail.MessagingException: Open failed;
        nested exception is:
           java.io.EOFException: EOF on socket
           at com.sun.mail.pop3.POP3Folder.open(POP3Folder.java:215)
      I wrote a simple Class to reproduce the error:
          private void execute() throws MessagingException {
              Properties props = new Properties();
              props.put("mail.smtp.host", "mail.smtp.host");
              props.put("mail.store.protocol", "pop3");
              // Session session = Session.getInstance(props, null);
              Session session = Session.getDefaultInstance(props);
              Store store = session.getStore("pop3");
              store.connect("mail.myDomain.com", "myUser", "myPassword");
              Folder inbox = store.getFolder("INBOX");
              inbox.open(Folder.READ_ONLY);
          }
      It connects to the store okay. The exception is thrown at the the line with store.getFolder("INBOX"). I've checked our firewall settings and email server settings (dovecot/postfix) and all seems well.

      Anyone have a clue what this might be?
        • 1. Re: EOF on socket when opening pop3 inbox
          Bshannon-Oracle
          What does the protocol trace show?
          http://www.oracle.com/technetwork/java/javamail/faq/index.html#debug
          • 2. Re: EOF on socket when opening pop3 inbox
            955077
            Thanks for your quick reply.

            Here's the trace:
            DEBUG: setDebug: JavaMail version 1.4.5
            DEBUG: getProvider() returning javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]
            DEBUG POP3: mail.pop3.rsetbeforequit: false
            DEBUG POP3: mail.pop3.disabletop: false
            DEBUG POP3: mail.pop3.forgettopheaders: false
            DEBUG POP3: mail.pop3.cachewriteto: false
            DEBUG POP3: mail.pop3.filecache.enable: false
            DEBUG POP3: mail.pop3.keepmessagecontent: false
            DEBUG POP3: mail.pop3.starttls.enable: false
            DEBUG POP3: mail.pop3.starttls.required: false
            DEBUG POP3: mail.pop3.apop.enable: false
            DEBUG POP3: mail.pop3.disablecapa: false
            DEBUG POP3: connecting to host "mail.myDomain.com", port 110, isSSL false
            S: +OK Dovecot ready.
            C: CAPA
            S: +OK
            CAPA
            TOP
            UIDL
            RESP-CODES
            PIPELINING
            STLS
            USER
            SASL PLAIN
            .
            DEBUG POP3: PIPELINING enabled
            DEBUG POP3: authentication command trace suppressed
            DEBUG POP3: authentication command succeeded
            C: STAT
            S: EOF
            C: QUIT
            S: EOF
            Exception in thread "main" javax.mail.MessagingException: Open failed;
              nested exception is:
                 java.io.EOFException: EOF on socket
                 at com.sun.mail.pop3.POP3Folder.open(POP3Folder.java:228)
                 at com.myTest.TestOpenInbox.execute(TestOpenInbox.java:26)
                 at com.myTest.TestOpenInbox.main(TestOpenInbox.java:13)
            Caused by: java.io.EOFException: EOF on socket
                 at com.sun.mail.pop3.Protocol.readResponse(Protocol.java:742)
                 at com.sun.mail.pop3.Protocol.simpleCommand(Protocol.java:687)
                 at com.sun.mail.pop3.Protocol.stat(Protocol.java:354)
                 at com.sun.mail.pop3.POP3Folder.open(POP3Folder.java:203)
                 ... 2 more
            It's Greek to me, but it appears everything is kosher until C:STAT S:EOF
            • 3. Re: EOF on socket when opening pop3 inbox
              Bshannon-Oracle
              I strongly suspect it's an authentication or authorization problem, even though
              the server isn't reporting an authentication failure. Try setting the session property
              "mail.debug.auth" to "true". You should get all the details of the authentication
              exchange, which might provide a clue as to what's wrong. (Just be careful when
              posting those details here so as not to expose your password.)

              It looks to me that the server is completing the authentication exchange and then
              closing the connection. You should probably look in the server log files as well.
              • 4. Re: EOF on socket when opening pop3 inbox
                955077
                I'm logging in ok:
                DEBUG POP3: PIPELINING enabled
                C: USER my.user
                S: +OK
                C: PASS myPassword
                S: +OK Logged in.
                C: STAT
                S: EOF
                C: QUIT
                S: EOF
                I should have mentioned though opening the inbox fails, it clears all the messages--Maildir/new is empty when it had messages before the attempt to open the inbox.

                I'll have to dig into the server logs.
                • 5. Re: EOF on socket when opening pop3 inbox
                  955077
                  Found and corrected the problem. The maillog had this:
                  Aug 12 01:01:13 279153-web1 dovecot: child 9328 (pop3) returned error 83 (Out of memory)
                  This was a strange error because I know there was plenty of memory on the system. Did some googling and found that an index file may have been corrupted and the remedy was to delete the file. I deleted the user's Maildir directory and now it's working fine. The cur directory was huge so I'm wondering if it was just that the inbox was full.