We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

IMAP: Aspose cannot connect to IMAP server

Hello

Situation: My program connects successfully to an IMAP server (groupwise) and processes a specific mailbox folder (that does not contain any emails) and shortly after disconnects from the server. After an interval of 6 seconds, it connects/disconnects again, etc. After about three hours of “seemingly” successful connecting to/disconnecting from the IMAP server, the following exception is thrown:

03.09.2017 04:20:00: [rechnung_test@kvsh.de] Could not connect to IMAP: AsposeException: ConnectFailure
—> AsposeException: ConnectFailure
—> System.IO.IOException: ConnectFailure —> System.Net.Sockets.SocketException: Ein Socketvorgang konnte nicht ausgeführt werden, da dem System Pufferspeicher fehlte oder eine Warteschlange voll war 172.20.10.65:143
bei System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
bei System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
bei #=qzrOSkxOYPko0PYrd2nwbcif63fuO2_lO3xUQd3mDOf8=.#=qG1jg_EEyY6YpdKRIAkSrFg==(Boolean #=qRCpKk5EE2O61ZC$g7nwMdA==, Socket #=qjyVqwqTakBlOidXawBpHZQ==, Socket #=qA6$YiW8P6ybSGCnDHdck4w==, Socket& #=qWw7XBkY8IZzvuZ8WMbATLg==, IPAddress& #=qQXCZDyzFRe5MdbrQt_AOCQ==, #=qSNFYMIb3FDMRlTgFmAIlwxsWbQohYYBQPtGbbmYuLh3QGgZ4w4FAVZ$Z9XNnNw8w #=qxuOcB9E1XXgu0jNfXUkRBg==, IAsyncResult #=qfVLafpoW38MI3FRBD1EbcA==, Int32 #=qvQHa7yfS809dRKUtA6dHhA==, Exception& #=qJeEagMZfqMuo4lQSr9x0hQ==)
— Ende der internen Ausnahmestapelüberwachung —
bei #=qzrOSkxOYPko0PYrd2nwbcif63fuO2_lO3xUQd3mDOf8=.#=quBFLwGOlXpoHh2xa5vDEKw==(#=qkhi20vrH$Otn75AnKzkueYAOZQVafhZOaMntQVKlAps= #=qMs5Z4ktA4mlpmAmP55iQgw==, Object #=qri0_x9FZJoWNZxRAMTKzQQ==, Boolean #=qOnbzI4S4zkP6teq1xxVMSw==, IPAddress& #=qQXCZDyzFRe5MdbrQt_AOCQ==, Socket& #=qzbGR59XAKWxvdUuj648pww==, Socket& #=qefiuQEOA_ihAwlhaf24PAQ==, Int32 #=qvQHa7yfS809dRKUtA6dHhA==)
bei #=qkhi20vrH$Otn75AnKzkueYAOZQVafhZOaMntQVKlAps=.#=qHNBZOjLYt0Jb9bXLd15Q0g==(Object #=qDUjyq$w55XrHQbvgPqKJ2g==, Boolean #=qOnbzI4S4zkP6teq1xxVMSw==, Int32 #=qvQHa7yfS809dRKUtA6dHhA==, #=qNXSjVdy1DPHEvC9imtgx5vufS5X$AX8p6TzXpr9dCab2MZ2eXqECRJ9knSKner_E #=qTNfA7eL37oXIN4E8Amebvg==)
bei #=qkhi20vrH$Otn75AnKzkueYAOZQVafhZOaMntQVKlAps=.#=qHNBZOjLYt0Jb9bXLd15Q0g==(Object #=qDUjyq$w55XrHQbvgPqKJ2g==, #=qNXSjVdy1DPHEvC9imtgx5vufS5X$AX8p6TzXpr9dCab2MZ2eXqECRJ9knSKner_E #=qTNfA7eL37oXIN4E8Amebvg==)
bei #=qR_BGhRogRav$Q2wwWkmS8rn$JvaBY2HeidEbjjctho4=.#=qqPxwOu8aLsoYxaOtNw9UdQ7_j13Mx39PqjE7sHUIu3g=(#=qzrOSkxOYPko0PYrd2nwbcif63fuO2_lO3xUQd3mDOf8= #=q1vqOap93jilIwMZ6RHKevQ==, Int32 #=qvQHa7yfS809dRKUtA6dHhA==)
bei #=q2jSOkNcJfQQ7ugdKgY57RS3LVw51eBlIB8pd9oSBMW6tG2qMa3UTul0NGCwqMBYv.#=qW1xC8mMKcDXdoJ6Anxy6dQy10Qt4iwuLSZguHHE2eOw=(String #=qQVDqL0lQiNcZiVBaWXdmIw==, Int32 #=q1Syl881CH2LGpss$7e10jQ==, SecurityOptions #=qi00CYDARSpYTAZC0XaJvHPY9lNn$PhduZgkHRCmPu$g=, Int32 #=qvQHa7yfS809dRKUtA6dHhA==)
bei #=q2jSOkNcJfQQ7ugdKgY57RS3LVw51eBlIB8pd9oSBMW6tG2qMa3UTul0NGCwqMBYv.#=qb79rykASBAitZOvBZHIJhnyj0YXN80oDrJ_aEs1Pw8w=(String #=qQVDqL0lQiNcZiVBaWXdmIw==, Int32 #=q1Syl881CH2LGpss$7e10jQ==)
— End of inner exception stack trace —
bei #=q2jSOkNcJfQQ7ugdKgY57RS3LVw51eBlIB8pd9oSBMW6tG2qMa3UTul0NGCwqMBYv.#=qb79rykASBAitZOvBZHIJhnyj0YXN80oDrJ_aEs1Pw8w=(String #=qQVDqL0lQiNcZiVBaWXdmIw==, Int32 #=q1Syl881CH2LGpss$7e10jQ==)
bei #=q2jSOkNcJfQQ7ugdKgY57RS3LVw51eBlIB8pd9oSBMW6tG2qMa3UTul0NGCwqMBYv.#=qqjhI6Ehxqm8iQ44Ac_5EMQmvEuAWlo2FuCna2XbVnXA=.#=qliGBGa8LOXg_Hbm4JRB2EsVnnMbpq9F75msxPWxb655KjU6v9Vollemhl89kBKYY()
— End of inner exception stack trace —
bei #=q2jSOkNcJfQQ7ugdKgY57RS3LVw51eBlIB8pd9oSBMW6tG2qMa3UTul0NGCwqMBYv.#=qnp_zJCJP27TSIi7tjEiMWuBMpRCFk9QIg2E9Y8318Qo=(String #=qQVDqL0lQiNcZiVBaWXdmIw==, Int32 #=q1Syl881CH2LGpss$7e10jQ==)
bei #=qHt0JB54ghnJrNqMP5KDpZKKbgs1WnE480gyTqqElitg=.#=qFeLVT3rbZwNnuVnlF0THWg==(Int32 #=qPys4XrHWLYgP_T7CwmICUg==)
bei #=qHt0JB54ghnJrNqMP5KDpZKKbgs1WnE480gyTqqElitg=.#=quBFLwGOlXpoHh2xa5vDEKw==()
bei Aspose.Email.Imap.ImapClient.BeginGetFolderInfo(String folderName, AsyncCallback callback, Object state)
bei Com.Kendox.MailArchiver.Library.MailProviders.Imap.ImapMailProvider.Connect(MergedProfile profile, Action`2 callback)

It seems to me that somehow the connections are not correctly closed. Or could another reason cause this faulty behaviour? I am using Aspose.Email 17.1.0.0.

My code:

ImapClient client = new ImapClient();		
client.Host = profile.ImapHostName;
client.Username = profile.MailBoxAddress;

string password = Encryption.ToInsecureString(profile.ImapMailBoxPassword);
if (string.IsNullOrEmpty(password))
{
   throw new ImapConnectionException("IMAP mailbox password is not set.");
}
client.Password = password;
client.Port = profile.ImapPortNumber;
...
ImapFolderInfo folderInfo = client.GetFolderInfo(ImapFolderInfo.InBox)
...

try
{
   client.CommitDeletes();
   client.Dispose();
}
catch (Exception ex) { }           
if (client != null)
   client = null;
}

Best Regards

Andreas

@pfa,

Thank you for contacting Aspose support team.

We have executed the test which will take few hours to complete. We will write back here soon to share the feedback once the test is completed.

@pfa,

Thank you for your patience. We have executed a test where ImapClient is used to connect and disconnect to a mail server about 11000 times in last 11 hours. No issue is observed and every time operation was executed successfully. It seems some issue with the mail server which you are using in your testing. Could you please share credentials of your test account for our testing here? It will help us to re-produce the scenario and provide assistance accordingly.

Thanks for your reply.

I cannot handover the credentials to our server before contacting our administrator who is on vacation.

Meanwhile I can tell you my newest findings. If testing connect/disconnect with a hMailServer for 10 hours, no problem occurs. If testing with a groupwise server, the exception is thrown after about three hours.

With what kind of server did you test?

@pfa,

Thank you for the feedback. My test account is on Exchange Server 2010. We will wait for the test account credentials and share our feedback once the issue is observed here using your test account.

@kashif.iqbal

I made a new connect/disconnect test with the newest version of Aspose.Email (17.9) and hMailServer. Thereby I detected that the connections are not closed because the hMailServer administration console only counts up the session numbers. Do you have an hMailServer available, so that you can check my observations? Or do you need a test account for our hMailServer? See image.png.

image.png (14.7 KB)

Is there something wrong with my code (see my first email)?

@pfa,

Unfortunately, we don’t have hMailServer installed at our end. We tried to configure one but getting some issues with it. If you could please share a test account’s credentials of your hMailServer with us, it would help us investigate the issue quickly to assist you further accordingly.

Also, we don’t see any issue with your code sample as client.Dispose is the line that disposes the ImapClient object. Still, we would request you to share a complete runnable code with us along with test credentials for further investigation at our end.