Reputation: 11
When there is no response from the server and I still make readresponse()
, It hangs there. Is there any timeout for this function?
Properties prop =new Properties();
prop.setProperty("mail.imap.port","993");
prop.setProperty("mail.imap.ssl.enable", "true");
prop.setProperty("mail.imaps.timeout", "5000");
Session session = Session.getDefaultInstance(prop);
IMAPProtocol protocol=new IMAPProtocol("username","imap.gmail.com",993,true,session.getDebugOut(), session.getProperties(),true);
protocol.login("username","password");
protocol.select("inbox");
protocol.idleStart();
protocol.readResponse();
Upvotes: 1
Views: 2284
Reputation: 11035
The com.sun.mail.imap documentation has a table at the bottom that lists all of the session properties you can set for IMAP. Set the mail.imap.timeout
and or mail.imaps.timeout
as the timeout in milliseconds.
Upvotes: 1