none
Unable to read data from the transport connection IMAP RRS feed

  • Question

  • I use IMap to read mails from gmail in c#. I have created multiple (five)TCP connections on same mailbox for faster data reading. Google allows 15 simultaneous for mailbox. 

    But I am getting the error while reading data from

    SslStream.Read(byte[] buffer, int offset, int count);

    saying "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.".

    I use following settings for your reference

    imap.gmail.com port:993

    Complete stack trace is as follows

    Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host.
    ERROR2015-07-09 08:21:52 – Stack Strace ::    at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
       at System.Net.Security._SslStream.StartWriting(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
       at System.Net.Security._SslStream.ProcessWrite(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
       at System.Net.Security.SslStream.Write(Byte[] buffer, Int32 offset, Int32 count)
     


    I have check solution on many forums but didn't get any solution.Can some one please suggest the solution for it.

    Thanks in advance

    Mayuresh

    Friday, July 10, 2015 2:11 PM

Answers

  • That error occurs when the remote server closed your connection.  You really need to work with the remote provider on this one.  It might have been that they blocked your request, you sent them data they didn't like or they were simply busy.  There is no way, at this point, to tell whether it is the data you're sending or the remote endpoint.

    Also note that irrelevant of how many remote connections Google allows your local machine and network can (and will) limit the # of simultaneous connections to a remote endpoint.  In the case of HTTP for example I believe the limit is 2 but that might have changed.

    Michael Taylor
    http://blogs.msmvps.com/p3net

    Friday, July 10, 2015 2:58 PM
    Moderator

All replies

  • That error occurs when the remote server closed your connection.  You really need to work with the remote provider on this one.  It might have been that they blocked your request, you sent them data they didn't like or they were simply busy.  There is no way, at this point, to tell whether it is the data you're sending or the remote endpoint.

    Also note that irrelevant of how many remote connections Google allows your local machine and network can (and will) limit the # of simultaneous connections to a remote endpoint.  In the case of HTTP for example I believe the limit is 2 but that might have changed.

    Michael Taylor
    http://blogs.msmvps.com/p3net

    Friday, July 10, 2015 2:58 PM
    Moderator
  • Thanks for you answer Michael. I have tried the by reducing the number of connections but facing same issue. The exception occurs inconsistently. I am able to read some data then exception is throws for some of the emails and again it starts working.
    Tuesday, July 14, 2015 6:10 AM
  • Network calls can do that.  It is the reason why you'll need to build in some sort of error handling/retry logic. If you consistently get an error when sending/receiving data then it is likely to the data itself. When it is sporadic it is either normal network issues or something on the server side. Only the host can answer that. Irrelevant you should decide how your app responds. In many cases simply reconnecting and trying again is appropriate. But to avoid continual failures you should set a limit on the # of retries. For example in most email clients it will retry 5-10 times before considering the server down. At that point the user is notified. Normal failures are common but continual failures are not.
    Tuesday, July 14, 2015 3:06 PM
    Moderator