tags:

views:

20

answers:

2

Hello,

I'm confronted to something disturbing. I'm setting up a POP account receiver, and it looks like it's working in some cases. When I connect to my server with the port 110, it's working OK (just have an error message when trying to connect with SSL, which is normal). But when I try the port 995, which should be working with SSL, it looks like javax.mail (1.4.3) is blocking while executing an input.readLine() command (marked as deprecated, BTW), instead of throwing the IOException it is supposed to throw...

I'm going to add a timeout to prevent this, but wanted to have your opinion on this. Does someone already experienced this? Any idea on how to get over it?

This is how I'm creating my Store object:

Properties pop3Props = new Properties();
        pop3Props.setProperty("mail.pop3.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
        pop3Props.setProperty("mail.pop3.socketFactory.fallback", "false");
        pop3Props.setProperty("mail.pop3.port", Integer.toString(hostPort));
        pop3Props.setProperty("mail.pop3.socketFactory.port", Integer.toString(hostPort));
        pop3Props.setProperty("mail.pop3.starttls.enable", String.valueOf(STARTTLS));
        pop3Props.setProperty("mail.pop3.auth", String.valueOf(AUTH));

        // Create session and URL
        Session session = Session.getInstance(pop3Props, null);
        session.setDebug(true);
        URLName url = new URLName(POP3, host, hostPort, "", username, password);

        // Create the store
        if (useSSL) {
            return new POP3SSLStore(session, url);
        } else {
            return new POP3Store(session, url);
        }

This is how I'm trying to connect on this object:

store.connect(host, hostPort, username, password);

And this is the javax.mail line which is making everything freeze (original comment included):

String line = input.readLine(); // XXX - readLine is deprecated

Thank you very much for your help!

Morgan

+1  A: 

I had a look at the file - I don't think the readLine() method is the problem. Since the DataInputStream is reading from a socket I'd try and check if there's a problem with the socket (e.g. you accidentally closed it) or with the parameters you provide to create the socket.

theseion
A: 

Woohoo! I actually found a way to bypass this! I just added a timeout on the connection!

pop3Props.setProperty("mail.pop3.timeout", "3000"); pop3Props.setProperty("mail.pop3.connectiontimeout", "3000");

Thanks a lot for everything! :)

blaguman
Ah, nice. Your welcome.
theseion