javax.mail blocking while trying to connect

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", "");
        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);
        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!



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! :)

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.

Need Your Help

Completing a socket connection across an intranet or internet

flex air p2p nat serversocket

I am writing a peer-to-peer binary socket program. There are only two endpoints. One socket is listening on my laptop system. The other socket is broadcasting from my desktop system. I have a t...

Char library which can scale the x axis correctly

javascript html5 charts

I am looking for a chart library in JavaScript.