locked
Unable to read data from the transport connection: net_io_connectionclosed --- How to resolve this error

    Question

  • Hi,

    I  created asp code for sending e-mail. The code works fine with small attachments. But when sending large files I get this error:

    "Unable to read data from the transport connection: net_io_connectionclosed"

    Can somebody help me resolve this issue please...

    Friday, July 30, 2010 6:01 AM

Answers

All replies

  • Check your timeout setting in application and mail server,

    it may caused by it~

     

    by the way, you can check the Max byte limit in both.


    小中中的學習筆記
    Friday, July 30, 2010 7:02 AM
  • Hi Albert,

    I had tried the smtp.Timeout option but it was no good. I have two options pending --- trying out the one you have mentioned and trying "smtp.ServicePoint.MaxIdleTime = 1"

    Will reply once I do that.

    MG

    Friday, July 30, 2010 7:08 AM
  • Hello Marble,

    here is one other thing you have to check,

    in your web.config, you can add a node in <system.web> like this:

    <system.web>
      <httpRuntime executionTimeout="90" maxRequestLength="4096" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" />
    </system.web>
    

    and change the attributes "executionTimeout", "maxRequestLength" as you need~

    PS: "maxRequestLength" is the byte of your request, it means the size of file when you are uploading some file.


    小中中的學習筆記
    Friday, July 30, 2010 7:38 AM
  • Hi Albert,

    I tried your advice, but no success yet. Posting you the code for reference. This is a Windows forms application.

    cs code:

    MailMessage mail = new MailMessage();
    mail.To.Add(tbTo.Text);
    mail.From = new MailAddress(tbLogin.Text);
    mail.Subject = tbSub.Text;
    mail.Body = tbBody.Text;
    mail.IsBodyHtml = true;
    mail.Attachments.Add(new Attachment(spath));
    SmtpClient smtp = new SmtpClient();
    smtp.Host = "smtp.gmail.com"; 
    smtp.Port = 465;//I have also tried the 587 option here
    smtp.UseDefaultCredentials = true;
    smtp.Credentials = new System.Net.NetworkCredential (tbLogin.Text, tbPass.Text);
    smtp.EnableSsl = true;
    smtp.Timeout = 3000000;
    smtp.ServicePoint.MaxIdleTime = System.Threading.Timeout.Infinite;//1;
    smtp.EnableSsl = true;
    smtp.Send(mail);
    
    

    App config:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
     <system.web>
      <httpRuntime executionTimeout="90" maxRequestLength="10000"/>
     </system.web>
    
    </configuration>
    
    Thanks for the help till now.
    Saturday, July 31, 2010 2:01 AM
  • Hello.

    Gmail normally has the limit of 25 MB for sending the entire email message including attachment. So it might close connection by itself. Please try something smaller than that size and see how the server respond.


    A marked answer is appreciated.
    Monday, August 02, 2010 2:03 AM
    Moderator
  • Maybe you can divide the attachment into small partitions,

    and run a loop to send them~ here are two samples to do this:

    Split and Merge Files

    File Merger and Splitter in C#


    小中中的學習筆記
    Monday, August 02, 2010 2:18 AM
  •  
    

    Hello Everyone,

    Thanks a lot for your responses. I have resolved the issue. I debugged the application and in the end it works fine :) I don't use app.config now. Pasting the cs code below. Perhaps it has got to do with Timeout alone.

     

      MailMessage mail = new MailMessage();
      mail.To.Add(tbTo.Text);
      mail.From = new MailAddress(tbLogin.Text);
      mail.Subject = tbSub.Text;
      mail.Body = tbBody.Text;
      mail.IsBodyHtml = true;
       mail.Attachments.Add(new Attachment(spath));
      SmtpClient smtp = new SmtpClient();
      smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
      //smtp.Port = 465;
      //smtp.UseDefaultCredentials = true;
      smtp.Credentials = new System.Net.NetworkCredential(tbLogin.Text, tbPass.Text);
      //smtp.EnableSsl = true;
      smtp.Timeout = 30000000;
      //smtp.
      //smtp.ServicePoint.MaxIdleTime = System.Threading.Timeout.Infinite;//1;
      //Or your Smtp Email ID and Password
      smtp.EnableSsl = true;
      smtp.Send(mail);
    
    

    Once again, thank you all for your responses.

    Regards,

    Marblegiraffe

    Monday, August 02, 2010 10:36 AM