Results 1 to 1 of 1
- 06-30-2010, 11:39 AM #1
Member
- Join Date
- Jun 2010
- Posts
- 1
- Rep Power
- 0
JavaMail API giving SocketTimeoutException intermittently
Problem Statement:
I have created a utility(using JavaMail API) which downloads mails from the Exchange Server 2003(MS Windows server 2003) using IMAP service.
The utility uses 5 different threads(each creating it's own separate IMAP session) to download the mails from the same user mailbox account. A separate main controlling thread has been used, which feeds these 5 threads with the start-end message counts with a batching of 100 messages. The 5 threads also set the message delete flag after downloading/processing the messages. And finally the main controlling thread expunges the mail box account after a certain amount of time(1 hour). (The service also takes care of expunging the messages at the startup as well.)
The utility runs fine for a long time(say 8 to 10 hours) but then it suddenly starts giving socket timeout exceptions and then it continues giving the exceptions. I even introduced a delay of 15 min. and increased the socket timeout period but to no avail. All i had to do was to restart the exchange server and after some time, i again started the utility and it worked finely.
Exception stack trace:
* BYE JavaMail Exception: java.net.SocketTimeoutException: Read timed out
javax.mail.MessagingException: * BYE JavaMail Exception: java.net.SocketTimeoutException: Read timed out;
nested exception is:
com.sun.mail.iap.ConnectionException: * BYE JavaMail Exception: java.net.SocketTimeoutException: Read timed out
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPSt ore.java:477)
at javax.mail.Service.connect(Service.java:275)
at com.newgen.omni.mail.mswrapper.MailServerWrapper.c onnect(MailServerWrapper.java:102)
at com.newgen.omni.mail.mswrapper.MailServerWrapper.< init>(MailServerWrapper.java:33)
at com.newgen.omni.mail.scheduler.Scheduler.Process(S cheduler.java:352)
at com.newgen.omni.mail.scheduler.Scheduler.run(Sched uler.java:293)
at com.newgen.omni.mail.scheduler.Scheduler.execute(S cheduler.java:1026)
at org.quartz.core.JobRunShell.run(JobRunShell.java:1 78)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run (SimpleThreadPool.java:477)
Caused by: com.sun.mail.iap.ConnectionException: * BYE JavaMail Exception: java.net.SocketTimeoutException: Read timed out
at com.sun.mail.iap.Protocol.handleResult(Protocol.ja va:299)
at com.sun.mail.iap.Protocol.simpleCommand(Protocol.j ava:316)
at com.sun.mail.imap.protocol.IMAPProtocol.login(IMAP Protocol.java:290)
at com.sun.mail.imap.IMAPStore.login(IMAPStore.java:5 17)
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPSt ore.java:458)
... 8 more
The code snippet to make the IMAP connection (all the 6 threads call it separately to create separate sessions):
Properties prop = new Properties();
logger.debugMsg("mailCapture :: Process :: Initializing IMAP context...");
prop.put("mail.imap.appendbuffersize","-1");
prop.put("mail.imap.allowreadonlyselect","true");
prop.put("mail.imap.separatestoreconnection","true ");
prop.put("mail.imap.partialfetch","false");
prop.put("mail.imap.connectiontimeout", "1200000");
prop.put("mail.imap.timeout", "1200000");
session = Session.getInstance(prop);
//session.setDebug(true);
logger.debugMsg("mailCapture :: Process :: Get Store...");
store = session.getStore("imap");
try
{
store.connect(mailServerInfo.strServerIP, Integer.parseInt(mailServerInfo.strServerPort), mailServerInfo.strUsername, mailServerInfo.strPassword);
}
catch(MessagingException ex)
{
logger.logException(ex.getMessage(), ex);
Thread.sleep(900000);
throw ex;
}
Please tell me what can be the possible cause and how to rectify it?
Regards
Nitin
Similar Threads
-
cant print 2d array(giving null values)
By fneeks in forum New To JavaReplies: 1Last Post: 04-07-2010, 08:48 PM -
Giving Inputs to Java Applet
By rasikh in forum Java AppletsReplies: 2Last Post: 10-05-2009, 03:08 PM -
Problem .... sockettimeoutException not thrown
By Shiv in forum NetworkingReplies: 0Last Post: 06-08-2009, 09:59 PM -
closing form and giving focus to all parents?
By saeed144 in forum New To JavaReplies: 3Last Post: 04-08-2009, 04:11 PM -
Giving Warning
By tanmoy.b81 in forum New To JavaReplies: 1Last Post: 12-24-2008, 09:21 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks