Fetching mails through IMAP gets errors

@Andrey_Potapov

The code sample updated i provided to you throws error at 2 points

1.) After a FetchMessage timeouts at n consecutive attempts. (n being set in config file)
2.) When we create the ImapClient instance. (here i can clear the throw statement and try executing)

and finally can i expect the new version of the assembly/package Aspose.Email as you mentioned dated March 24th in mail sequence below:

@yogesh.chhabra,
The fix will be available in Aspose.Email 20.3 at the end of the month.

Please update

Thanks & Regards

@yogesh.chhabra,
Please share the stack traces for the errors you are mentioned.

@Andrey_Potapov

I have shared the stack traces for the errors in the first post at ticket, still sharing the same here below:

Error 1:

2021-03-10 11:39:04 AM Error : An error occured while connecting ImapClient: AsposeException: AE_19_1_0002 NO [ALERT] Too many simultaneous connections. (Failure)
—> AsposeException: AE_19_1_0002 NO [ALERT] Too many simultaneous connections. (Failure)
—> ImapException: AE_19_1_0002 NO [ALERT] Too many simultaneous connections. (Failure)
at #=z6TzmIggaYr6gD28pVgp0qByzI0JZVGBkoUZVhuc=.#=z_f_ExuyvRxcM(ImapStatusCode #=z4G$MC057gMcE)
at #=z6TzmIggaYr6gD28pVgp0qByzI0JZVGBkoUZVhuc=.#=z_f_ExuyvRxcM()
at #=zsHxOtS1goAzXbIQbtNY5m4EnE0aI_hvyb_S$M6s=.#=z_f_ExuyvRxcM()
at #=zTpLdX8wJlC2agKejk0nsqf0xZQbCgHNLzeerPuk=.#=z7yV$8PU=(Object #=zO2V14KI=)

— End of inner exception stack trace —
at #=zMZ44ezK26MiKX5sPsHneBnY$Zn3WKCEOvE8rnzs=.#=zPIlx_bumk0Ku(String #=zkDSUT78=, Int32 #=zSO_ZBkE=)
at #=zMZ44ezK26MiKX5sPsHneBnY$Zn3WKCEOvE8rnzs=.#=z6krqkzs=()
at #=z0o7OEGSSyGZViRTqkm67$j45hE8t1t1bpQ==.#=z8s4HVptJA8z0()
— End of inner exception stack trace —
at #=zKsMZoQj7V8171J04kxP4KAui0J22.#=zxd769ac=(IAsyncResult #=zFBSKbgk=)
at #=zKsMZoQj7V8171J04kxP4KAui0J22.#=zoIFp4rM=()
at #=zCnpIhNu9ggZ6Em3x4Onn$N0iPaWQ.#=zPhsfbaLMbyEb(Int32 #=zDtVxeBo=, #=zfCU2qSy0a2_ihcIx82G4kNbg87UQ3qUIXQ== #=zzrMQxkc=)
at #=zKsMZoQj7V8171J04kxP4KAui0J22.#=zc20PShB5S7PN()
at #=zw$jR9sEqiBJWrRnUtmyNZMOwUM11wCi7dPd9oat6w$51.#=zc20PShB5S7PN()
at #=z4QXz97stZN24l4rqXV3xqGGnA9czZjxGMOdxPeiBI$1K…ctor(EmailClient #=zVtlkI7c=, String #=z9AND5dU=, Nullable1 #=zdYSWcIIDDBvN) at Aspose.Email.Clients.Imap.ImapClient.BeginSelectFolder(IConnection connection, String folderName, Nullable1 readOnly, AsyncCallback callback, Object state)
at Aspose.Email.Clients.Imap.ImapClient.SelectFolder(IConnection connection, String folderName, Nullable1 readOnly) at Aspose.Email.Clients.Imap.ImapClient.SelectFolder(String folderName) at Onguard.Email.Clients.ImapMailClient.<OnGetClientAsync>d__7.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Onguard.Email.Clients.MailClient2.d__7.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Onguard.Email.Clients.MailClient`2.get_Client()
at Onguard.Email.Clients.ImapMailClient.ConnectAsync()
2021-03-10 11:39:04 AM Error : Connection can not be established for setting UUID 8


Error 2:

An error occured while creating ImapMailClient: TimeoutException: The operation ‘Connect’ terminated. Timeout ‘100000’ has been reached.
at #=zKsMZoQj7V8171J04kxP4KAui0J22.#=zxd769ac=(IAsyncResult #=zFBSKbgk=)
at #=zKsMZoQj7V8171J04kxP4KAui0J22.#=zoIFp4rM=()
at #=zCnpIhNu9ggZ6Em3x4Onn$N0iPaWQ.#=zPhsfbaLMbyEb(Int32 #=zDtVxeBo=, #=zfCU2qSy0a2_ihcIx82G4kNbg87UQ3qUIXQ== #=zzrMQxkc=)
at #=zKsMZoQj7V8171J04kxP4KAui0J22.#=zc20PShB5S7PN()
at #=zw$jR9sEqiBJWrRnUtmyNZMOwUM11wCi7dPd9oat6w$51.#=zc20PShB5S7PN()
at #=z4QXz97stZN24l4rqXV3xqGGnA9czZjxGMOdxPeiBI$1K…ctor(EmailClient #=zVtlkI7c=, String #=z9AND5dU=, Nullable1 #=zdYSWcIIDDBvN) at Aspose.Email.Clients.Imap.ImapClient.BeginSelectFolder(IConnection connection, String folderName, Nullable1 readOnly, AsyncCallback callback, Object state)
at Aspose.Email.Clients.Imap.ImapClient.SelectFolder(IConnection connection, String folderName, Nullable1 readOnly) at Aspose.Email.Clients.Imap.ImapClient.SelectFolder(String folderName) at Onguard.Email.Clients.ImapMailClient.d__7.MoveNext() 2021-03-18 5:29:25 PM Error : An error occured while connecting ImapClient: TimeoutException: The operation ‘Connect’ terminated. Timeout ‘100000’ has been reached. at #=zKsMZoQj7V8171J04kxP4KAui0J22.#=zxd769ac=(IAsyncResult #=zFBSKbgk=) at #=zKsMZoQj7V8171J04kxP4KAui0J22.#=zoIFp4rM=() at #=zCnpIhNu9ggZ6Em3x4Onn$N0iPaWQ.#=zPhsfbaLMbyEb(Int32 #=zDtVxeBo=, #=zfCU2qSy0a2_ihcIx82G4kNbg87UQ3qUIXQ== #=zzrMQxkc=) at #=zKsMZoQj7V8171J04kxP4KAui0J22.#=zc20PShB5S7PN() at #=zw$jR9sEqiBJWrRnUtmyNZMOwUM11wCi7dPd9oat6w$51.#=zc20PShB5S7PN() at #=z4QXz97stZN24l4rqXV3xqGGnA9czZjxGMOdxPeiBI$1K…ctor(EmailClient #=zVtlkI7c=, String #=z9AND5dU=, Nullable1 #=zdYSWcIIDDBvN)
at Aspose.Email.Clients.Imap.ImapClient.BeginSelectFolder(IConnection connection, String folderName, Nullable1 readOnly, AsyncCallback callback, Object state) at Aspose.Email.Clients.Imap.ImapClient.SelectFolder(IConnection connection, String folderName, Nullable1 readOnly)
at Aspose.Email.Clients.Imap.ImapClient.SelectFolder(String folderName)
at Onguard.Email.Clients.ImapMailClient.d__7.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Onguard.Email.Clients.MailClient2.d__7.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Onguard.Email.Clients.MailClient2.get_Client()
at Onguard.Email.Clients.ImapMailClient.ConnectAsync()


Thanks,

@yogesh.chhabra,
Thank you for the additional information. Our development team will investigate this case further.

@Andrey_Potapov
In my application code i updated the Aspose.Email.dll to version 20.11.0.0 to fetch mails, only gets me the referred errors.

Earlier the version 19.2.0.0 of Aspose.Email.dll was being used, which had never got any such errors.

Please consider it.

Thanks,

@yogesh.chhabra,
Our development team performed an additional investigation and found no errors on our side. The error “Too many simultaneous connections. (Failure)” is related to the count of connections created by you. You should avoid creating new connections and new instances of ImapClient. If you have to create a new ImapClient instance, you should make sure that there are not too many such instances. You also should understand that this limit for simultaneous connections can occur if there are other email clients connected to this account. For example, there could be Thunderbird or other mail applications connected. Some mail clients create more than one connection to the server.

The error “TimeoutException: The operation ‘Connect’ terminated” is actually the same as the previous one, it just occurs during an extra connecting attempt. It happens because the email server does not provide any responses when there are too many simultaneous connections. We think it is the DDOS attack prevention mechanism. In this case, we wait for any response from the server for a specified amount of time. When time is out, we throw a timeout exception. You should not try to create another connection when you already received the “Too many simultaneous connections” error. You should close old connections first.

As we can see from the sample code you provided, n is equal to 0. In this case, there could be a timeout error when the access token is expired. You use Microsoft Oauth authentication. This authentication mechanism provides access tokens that expire every hour. Throwing the TimeoutException is a bug, we fixed it last week, and the fix will be available in version 21.4. BTW, in the new version, you will also get an exception when your token gets expired. The only difference is that it will not be a TimoutException. We will throw an ImapException instead and this exception will provide information about the access token expiration. The other reason for the timeout exception could be related to the real timeouts. Our development team tried to reproduce the error using the Sample code, but everything works without any unnecessary errors on our side. There could be connection issues in the environment you use.

We are not sure we understood this one. Maybe you mean the “Too many simultaneous connections” error. If so, our developers have already analyzed this one above.

A code example that should work for several hours/days until an error occurs is not suitable for us. The code sample should reproduce the error for at least an hour. If it is not possible to provide such a sample code, we would ask you to find out which version exactly after 19.2 the error starts to occur.

@Andrey_Potapov
For the errors mentioned:

  1. Too many simultaneous connections, i tried to make use of the default connection and not call the statement CreateConnection which doesn’t add to the connection count. This seems working fine, rest could be sure at a large scale testing.
  2. TImeOut error, you mentioned it has been fixed by team last week and will be available in 21.4, when can it be expected? Please clarify.

Regards this, we had the referred versions 19.2 and 20.11 available so cannot say of the version the error started up. Probably you shall be more aware of it, through the tickets :slightly_smiling_face:.

Thanks & Regards,

@yogesh.chhabra,

Unfortunately, a fix for this issue was made a little after the release of version 21.3. Therefore, the fix will be available in Aspose.Email 21.4. We apologize for any inconvenience caused.

@Andrey_Potapov
Any tentative date for the 21.4 version of Aspose.Email library ?

@yogesh.chhabra,
Aspose.Email 21.4 will be released towards the end of April. After that, you will receive an automatic notification within one or two days.

Hi @Andrey_Potapov,

When you are expecting to deliver this fix?

@marieke.saeij,
The fix will be included in Aspose.Email 21.4. This release will be published in the next few days. Thank you for your patience.

The issues you have found earlier (filed as EMAILNET-40170) have been fixed in this update.

@Andrey_Potapov / Aspose Team
Thanks for the updates. We will get the updated version, and hope the error mentioned shall no longer be encountered with it.

Thanks once again

Regards,
Yogesh