Aspose Email Stops Reading Mails From Inbox Post throwing request timed out WebException


#1

Aspose Email Stops Reading Mails From Inbox Post throwing request timed out WebException. This issue happens only in AWS Windows/ Linux environment .

Following code snippet to get the connection

NetworkCredential credentials = new NetworkCredential(userName, password, “”);
String mailboxUri = “https://outlook.office365.com/ews/exchange.asmx”;
IEWSClient client = EWSClient.getEWSClient(mailboxUri, credentials);


#2

@anand_bhavi_arisglobal_com,

Thank you for contacting Aspose Support.

We were unable to reproduce the issue on Linux using the latest version of Aspose.Email for Java API. It is requested that you try connecting from a different network. If possible, please share the test account credential so that we can investigate this scenario further. The screenshot of the result is also attached for your reference.
EWSClient.png (52.9 KB)


#3

Hi ahmad,

The issue doesn’t occur in normal Windows/Linux setup. It happen’s only in AWS Windows/Linux set up that too post 4 - 5 hours . Up to 4 - 5 hour’s system will be able to connect to inbox and read the mails. Once we restart the our application then again it’s works up to 4- 5 hours.

Since connection is established through web services , is there any settings suggested for AWS environment to work seamlessly without re-start of our application.


#4

@anand_bhavi_arisglobal_com,

Thank you for your feedback.

Our API does not provide any environment specific settings. As long as the environment is compatible, the same code should work. Additionally, the request timed out exception is a very generic which can arise due to a variety of reasons.
If possible, please provide the details given below so that we can investigate the scenario further.

  • Complete stack trace.
  • Complete environment details.
  • Complete code snippet in which you are executing the code provided in your initial message.

#5
  • Complete stack trace: ERROR com.arisglobal.ate.agx.email.EWSEmailProcessorImpl.error() - getConnection() - Exception while getting outlook Connection
    java.lang.IllegalStateException: class com.aspose.email.system.exceptions.WebException: The request timed out
    com.aspose.email.internal.m.z.w(Unknown Source)
    com.aspose.email.nr.a(SourceFile:213)
    com.aspose.email.nr.a(SourceFile:305)
    com.aspose.email.EWSClient.getEWSClient(SourceFile:297)
    com.aspose.email.EWSClient.getEWSClient(SourceFile:75)
    com.arisglobal.ate.agx.email.EWSEmailProcessorImpl.getConnection(EWSEmailProcessorImpl.java:73)
    com.arisglobal.ate.agx.email.EWSEmailProcessorImpl.saveAll(EWSEmailProcessorImpl.java:158)
    com.arisglobal.ate.agx.irt.helper.IRTEmailAdapterHelper.readEmailCase(IRTEmailAdapterHelper.java:220)
    com.arisglobal.ate.agx.irt.IRTEmailTaskCreator.poll(IRTEmailTaskCreator.java:84)
    com.arisglobal.ate.work.AbstractThreadPoolWorker.run(AbstractThreadPoolWorker.java:148)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    java.lang.Thread.run(Thread.java:748)
    at com.aspose.email.nr.a(SourceFile:241) ~[aspose-email-6.5.0.0-jdk16.jar:6.5.0.0]
    at com.aspose.email.nr.a(SourceFile:305) ~[aspose-email-6.5.0.0-jdk16.jar:6.5.0.0]
    at com.aspose.email.EWSClient.getEWSClient(SourceFile:297) ~[aspose-email-6.5.0.0-jdk16.jar:6.5.0.0]
    at com.aspose.email.EWSClient.getEWSClient(SourceFile:75) ~[aspose-email-6.5.0.0-jdk16.jar:6.5.0.0]
    at com.arisglobal.ate.agx.email.EWSEmailProcessorImpl.getConnection(EWSEmailProcessorImpl.java:73) [ate.jar:?]
    at com.arisglobal.ate.agx.email.EWSEmailProcessorImpl.saveAll(EWSEmailProcessorImpl.java:158) [ate.jar:?]
    at com.arisglobal.ate.agx.irt.helper.IRTEmailAdapterHelper.readEmailCase(IRTEmailAdapterHelper.java:220) [ate.jar:?]
    at com.arisglobal.ate.agx.irt.IRTEmailTaskCreator.poll(IRTEmailTaskCreator.java:84) [ate.jar:?]
    at com.arisglobal.ate.work.AbstractThreadPoolWorker.run(AbstractThreadPoolWorker.java:148) [ate.jar:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_131]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_131]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_131]
    Caused by: com.aspose.email.system.exceptions.WebException: The request timed out
    at com.aspose.email.internal.m.z.w(Unknown Source) ~[aspose-email-6.5.0.0-jdk16.jar:6.5.0.0]
    at com.aspose.email.nr.a(SourceFile:213) ~[aspose-email-6.5.0.0-jdk16.jar:6.5.0.0]
    … 11 more

  • Complete environment details:
    OS : Centos 7 64 Bit
    Java: JDK 1.8

  • Complete code snippet in which you are executing the code provided in your initial message:
    private IEWSClient client;

/**
* This method is used to get connection
* getConnection ().
* @return Connection
*
*/
public IEWSClient getConnection() {
if (isTraceEnabled) {
logger.trace(“getConnection() for EWSEmail- start”);
}
if (isInfoEnabled) {
logger.info(“getConnection() - getting EWSEmail the connection for User : “,
userName, “”);
}
try {
NetworkCredential credentials = new NetworkCredential(userName, password, “”);
logger.info(“Host Name:” + host);
logger.info(“userName Name:” + userName);
String mailboxUri = “https://”+host+”/ews/exchange.asmx”;
logger.info(“mailboxUri:” + mailboxUri);
client = EWSClient.getEWSClient(mailboxUri, credentials);

	} catch (Exception e) {
		logger.error(
				"getConnection() - Exception while getting outlook Connection ",
				e);
	}

	if (isTraceEnabled) {
		logger.trace("getConnection() for EWSEmail - end");
	}
	return client;
}

/**
 * This method will close  Imap connection 
 * closeConnection ().
 * @return Boolean
 * 
 */

public boolean closeConnection() {
	
	if (isTraceEnabled) {
		logger.trace("closeConnection() for EWSEmail- start");
	}
	boolean retValue = true;
	try {
		client.dispose();
	}catch(Exception e) {
		retValue = false;
	}
	if (isTraceEnabled) {
		logger.trace("closeConnection() for EWSEmail - end");
	}
	return retValue;
}

/**
 * This method will get Message email Count of EWSEmail connection 
 * getMessagesCount ().
 * @return Int 
 * 
 */

public int getMessagesCount() {
	return client.listMessages(client.getMailboxInfo().getInboxUri()).size();
}

   /**
 * This method will Read the Mail from mail box and save the eml in specified folder 
 * and it helps to take Back up of eml and send mail to ack up eml
 * @param TaskDao , TaskContext
 * @return Boolean.
 * 
 */

public boolean saveAll(TaskDao irtTaskDao, TaskContext taskContext)
		throws Exception {

	if (isTraceEnabled) {
		logger.trace("saveAll(TaskDao irtTaskDao, TaskContext taskContext)- start");
	}
	boolean retValue = true;
	getConnection();
	if (client != null) {
		
	
	if (maxNumberOfMessages == 0) {
		maxNumberOfMessages = getMessagesCount();
	}
	List<Long> taskIdList = new ArrayList<Long>();
	ExchangeMessageInfoCollection msgCollection = client.listMessages(client.getMailboxInfo().getInboxUri());
	for (ExchangeMessageInfo msgInfo : msgCollection) {
		try {
			MailMessage eml = client.fetchMessage(msgInfo.getUniqueUri());
			Long messageSeq = irtTaskDao
					.getNextSequence(IRT_EMAIL_DB_SEQUENCE_FOR_EMAIL_FILENAME);
			if (isInfoEnabled) {
				logger.info(
						"saveAll(TaskDao irtTaskDao, TaskContext taskContext) - Saving Mail to eml and Taking Back up for Task id and User Id: ",
						taskContext.getLinkedRecordId()+ " ," + userName ," ");
			}
			eml.save(emlPath + File.separator + messageSeq + ".eml",
					SaveOptions.getDefaultEml());
			if(partner.getIsemailBackupreq()){
				performBackup(partner, eml,
						String.valueOf(taskContext.getLinkedRecordId()),
						String.valueOf(messageSeq));
			}
			client.deleteMessage(msgInfo.getUniqueUri(),true);
			Long recordId = irtTaskDao.createTask(TaskType.IRT_EMAIL,
					TaskStatus.CREATED_IDLE,
					taskContext.getLinkedRecordId(),
					String.valueOf(messageSeq));
			taskIdList.add(recordId);
		} catch (Exception e) {
			logger.error(
					"saveAll(TaskDao irtTaskDao, TaskContext taskContext) ",
					e);
		}
	}
	if (null != taskIdList && !taskIdList.isEmpty()) {
		irtTaskDao.updateInProgressStatus(taskIdList,
				TaskStatus.CREATED_ACTIVE);
	}
	closeConnection();
	if (isTraceEnabled) {
		logger.trace("saveAll(TaskDao irtTaskDao, TaskContext taskContext)- end");
	}
	}
	return retValue;
}

#6

Please let me know is there any manual ways to identify whether the request time out is occurring while retrieving WSLD file or authenticating credentials.


#7

@anand_bhavi_arisglobal_com,

Thank you for your feedback.

By reviewing the stack trace that you shared, we observed that you were using an older version of Aspose.Email API whereas, it is always recommended to use the latest version of the API because it contains the latest enhancements and features.

By looking at the stack trace, it seems that the issue is related to authentication however, we cannot share additional details unless we are able to replicate the issue in our environment using the latest version of the API. Please test this scenario using Aspose.Email for Java 18.11 and in case the issue persists, please share the respective stack trace.


#8

We have tried with aspose-email-18.9-jdk16.jar , but still issue persist. We have found two types of Timed Out Exception. Following are the stack trace.

java.lang.IllegalStateException: class com.aspose.email.system.exceptions.WebException: The request timed out
com.aspose.email.internal.o.ab.b(Unknown Source)
com.aspose.email.internal.o.ab.y(Unknown Source)
com.aspose.email.rc.a(SourceFile:260)
com.aspose.email.rc.a(SourceFile:352)
com.aspose.email.of.a(SourceFile:430)
com.aspose.email.of.d(SourceFile:352)
com.aspose.email.of.getMailboxInfo(SourceFile:297)
com.arisglobal.ate.agx.email.EWSEmailProcessorImpl.getMessagesCount(EWSEmailProcessorImpl.java:123)
com.arisglobal.ate.agx.email.EWSEmailProcessorImpl.saveAll(EWSEmailProcessorImpl.java:166)
com.arisglobal.ate.agx.irt.helper.IRTEmailAdapterHelper.readEmailCase(IRTEmailAdapterHelper.java:201)
com.arisglobal.ate.agx.irt.IRTEmailTaskCreator.poll(IRTEmailTaskCreator.java:84)
com.arisglobal.ate.work.AbstractThreadPoolWorker.run(AbstractThreadPoolWorker.java:148)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:748)
at com.aspose.email.rc.a(SourceFile:286) ~[aspose-email-18.9-jdk16.jar:18.9]
at com.aspose.email.rc.a(SourceFile:352) ~[aspose-email-18.9-jdk16.jar:18.9]
at com.aspose.email.of.a(SourceFile:430) ~[aspose-email-18.9-jdk16.jar:18.9]
at com.aspose.email.of.d(SourceFile:352) ~[aspose-email-18.9-jdk16.jar:18.9]
at com.aspose.email.of.getMailboxInfo(SourceFile:297) ~[aspose-email-18.9-jdk16.jar:18.9]
at com.arisglobal.ate.agx.email.EWSEmailProcessorImpl.getMessagesCount(EWSEmailProcessorImpl.java:123) ~[ate.jar:?]
at com.arisglobal.ate.agx.email.EWSEmailProcessorImpl.saveAll(EWSEmailProcessorImpl.java:166) ~[ate.jar:?]
at com.arisglobal.ate.agx.irt.helper.IRTEmailAdapterHelper.readEmailCase(IRTEmailAdapterHelper.java:201) [ate.jar:?]
at com.arisglobal.ate.agx.irt.IRTEmailTaskCreator.poll(IRTEmailTaskCreator.java:84) [ate.jar:?]
at com.arisglobal.ate.work.AbstractThreadPoolWorker.run(AbstractThreadPoolWorker.java:148) [ate.jar:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_131]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_131]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_131]
Caused by: com.aspose.email.system.exceptions.WebException: The request timed out
at com.aspose.email.internal.o.ab.b(Unknown Source) ~[aspose-email-18.9-jdk16.jar:18.9]
at com.aspose.email.internal.o.ab.y(Unknown Source) ~[aspose-email-18.9-jdk16.jar:18.9]
at com.aspose.email.rc.a(SourceFile:260) ~[aspose-email-18.9-jdk16.jar:18.9]
… 12 more

java.lang.IllegalStateException: class com.aspose.email.system.exceptions.WebException: The request timed out
com.aspose.email.internal.o.ab.x(Unknown Source)
com.aspose.email.rc.a(SourceFile:254)
com.aspose.email.rc.a(SourceFile:352)
com.aspose.email.EWSClient.getEWSClient(SourceFile:329)
com.aspose.email.EWSClient.getEWSClient(SourceFile:277)
com.aspose.email.EWSClient.getEWSClient(SourceFile:79)
com.arisglobal.ate.agx.email.EWSEmailProcessorImpl.getConnection(EWSEmailProcessorImpl.java:218)
com.arisglobal.ate.agx.email.EWSEmailProcessorImpl.saveAll(EWSEmailProcessorImpl.java:162)
com.arisglobal.ate.agx.irt.helper.IRTEmailAdapterHelper.readEmailCase(IRTEmailAdapterHelper.java:201)
com.arisglobal.ate.agx.irt.IRTEmailTaskCreator.poll(IRTEmailTaskCreator.java:84)
com.arisglobal.ate.work.AbstractThreadPoolWorker.run(AbstractThreadPoolWorker.java:148)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:748)
at com.aspose.email.rc.a(SourceFile:286) ~[aspose-email-18.9-jdk16.jar:18.9]
at com.aspose.email.rc.a(SourceFile:352) ~[aspose-email-18.9-jdk16.jar:18.9]
at com.aspose.email.EWSClient.getEWSClient(SourceFile:329) ~[aspose-email-18.9-jdk16.jar:18.9]
at com.aspose.email.EWSClient.getEWSClient(SourceFile:277) ~[aspose-email-18.9-jdk16.jar:18.9]
at com.aspose.email.EWSClient.getEWSClient(SourceFile:79) ~[aspose-email-18.9-jdk16.jar:18.9]
at com.arisglobal.ate.agx.email.EWSEmailProcessorImpl.getConnection(EWSEmailProcessorImpl.java:218) [ate.jar:?]
at com.arisglobal.ate.agx.email.EWSEmailProcessorImpl.saveAll(EWSEmailProcessorImpl.java:162) [ate.jar:?]
at com.arisglobal.ate.agx.irt.helper.IRTEmailAdapterHelper.readEmailCase(IRTEmailAdapterHelper.java:201) [ate.jar:?]
at com.arisglobal.ate.agx.irt.IRTEmailTaskCreator.poll(IRTEmailTaskCreator.java:84) [ate.jar:?]
at com.arisglobal.ate.work.AbstractThreadPoolWorker.run(AbstractThreadPoolWorker.java:148) [ate.jar:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_131]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_131]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_131]
Caused by: com.aspose.email.system.exceptions.WebException: The request timed out
at com.aspose.email.internal.o.ab.x(Unknown Source) ~[aspose-email-18.9-jdk16.jar:18.9]
at com.aspose.email.rc.a(SourceFile:254) ~[aspose-email-18.9-jdk16.jar:18.9]
… 12 more

The issue is observed only in AWS environment’s , Non AWS environment’s same code works fine.


#9

@anand_bhavi_arisglobal_com,

Thank you for your feedback.

As requested in our previous message, please test this scenario using Aspose.Email for Java 18.11 and share the respective stack trace and exception message if the issue persists. Please note that we cannot address the issue if it is not reproducible with the latest version of the API.