System.Net.Mail.SmtpException: net_io_connectionclosed

I'm getting "System.IO.IOException: Unable to read data from the transport connection: net_io_connectionclosed." but only occasionally. I'm confused because:

1) The SMTP server is the local machine so why would the connection ever fail? and
2) The error only happens sometimes

There was a similar question posted here: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=418540&SiteID=1 but it seems they were having problems sending any mail to begin with.

Here is the full stack trace:

System.Net.Mail.SmtpException: Failure sending mail. > System.IO.IOException: Unable to read data from the transport connection: net_io_connectionclosed.
at System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer, Int32 offset, Int32 read, Boolean readLine)
at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine)
at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller)
at System.Net.Mail.SmtpReplyReader.ReadLine()
at System.Net.Mail.CheckCommand.Send(SmtpConnection conn, String& response)
at System.Net.Mail.DataStopCommand.Send(SmtpConnection conn)
at System.Net.Mail.SmtpConnection.OnClose(Object sender, EventArgs args)
at System.Net.ClosableStream.Close()
at System.Net.Mail.MailWriter.Close()
at System.Net.Mail.SmtpClient.Send(MailMessage message)

I'm unable to recreate this error since it only happens every couple of days or even weeks.

Has anyone had a similar error and been able to resolve it?

Thanks.

[1569 byte] By [rycooder] at [2008-1-10]
# 1

I am having the exact same problem. It is an intermittent issue. I run the program without difficulties....next time it is run I get the failure message...I can leave it alone for an hour and run it again...sends fine.

I have checked the SMTP settings numerous times. There is no firewall issue. I know the data is good for the .to and .from since that data worked before and always works on subsequent attempts...eventually.

It almost seems to be a cache issue except I don't allow the page to be cached...but still after a period of time passes everything starts to work again without any changes.

Ken

WAFDOF95 at 2007-10-3 > top of Msdn Tech,.NET Development,.NET Framework Networking and Communication...

.NET Development

Site Classified