0 votes

Hello,

When we try to receive a specific message from Mail Server (with IMAP. 143 port), we get the below exception. We retry to receive it a lot of times, but we getting the same exception.

The receive timeout parameter is set to 180 seconds.

Could you please help us?

Tried to read 56460 bytes, only 56423 received. Please make sure that antivirus and firewall software are disabled or configured correctly. ---> System.Exception: Tried to read 56460 bytes, only 56423 received. ---> System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

by (1.2k points)

1 Answer

0 votes

IMAP server is not returning correct (declared) number of bytes.

Make sure you are using SSL/TLS, and AV software is not running.

You may also turn on logging, to see the raw IMAP client - server communication:
https://www.limilabs.com/blog/logging-in-mail-dll

Most likely the message is broken on the server and it cuts connection at some point.

If you had tried several times, there is nothing you can do about it.

by (300k points)
Further to my above message, we not using SSL/TLS connection  neither AV software is not running.

Is there any work around to receive this message?
In every mail client it is possible to receive it.
I don't think there is a workaround. It looks like this server is breaking the protocol completely.

Try using SSL/TLS or a different machine, so you are sure, that the connection is not cut because of some AV software you are not aware of.

Additionally take a look at the logs just to be sure.
We provide you the following detailed log.

AV it is not running.

This exception raised only in a few messages and we have received thousands (~one exception per 50.000 messages)

2019-06-07 16:11:37,928 [69] INFO  Mail.dll.InvokeMethod() - C: 2F000005 UID FETCH 55459 (UID BODY.PEEK[])
2019-06-07 16:11:37,934 [69] INFO  Mail.dll.InvokeMethod() - S: * 55451 FETCH (UID 55459 BODY[] {56460}
2019-06-07 16:14:38,461 [69] ERROR ************Software.************.Service.MailProtocol.IMAP.IMapApi.IMapReceiveMessage() - Exception in IMailApi.ReceiveMessage(...) - Message IMAP UID: 55459 from Unibox with UNI_Guid: 49ae3c23-1aef-e811-b803-005056a1f450, UNI_EmailAddress: marine@*******.gr, EML_Guid: ea3c8599-5ab9-4cf1-abb7-dec9f60ea2ce
Limilabs.Client.ServerException: Tried to read 56460 bytes, only 56423 received. Please make sure that antivirus and firewall software are disabled or configured correctly. ---> System.Exception: Tried to read 56460 bytes, only 56423 received. ---> System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at     .  (Int32 count, Stream destination)
   --- End of inner exception stack trace ---
   at     .  (Int32 count, Stream destination)
   --- End of inner exception stack trace ---
   at     .  (Int32 count, Stream destination)
   at     .  (Int32 count, Stream destination)
   at     . (MemoryStream memory)
   at     . ()
   at Limilabs.Client.IMAP.ImapResponse. (Stream reader)
   at Limilabs.Client.IMAP.Imap.  (ImapResponse response)
   at Limilabs.Client.IMAP.Imap.   (ImapCommand command, Boolean throwException)
   at Limilabs.Client.IMAP.Imap.PeekMessageByUID(Int64 uid)
   at ************Software.************.Service.MailProtocol.IMAP.IMapApi.IMapReceiveMessage(Int64 receiveUID)
There is no way to recover from this error. Server doesn't send promised count of bytes for this message.
...