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

johna by | May 6, 2020 | Web Development



I have been facing a problem with an ASP.NET application that sends email using a remote mail server.

Some emails failed to send, and the error message logged was "Unable to read data from the transport connection: net_io_connectionclosed".

The problems were very intermittent and started occurring after a change of mail server. It was not easy to reproduce the problem.

I didn't get much help from the people supporting the new mail server, although they did confirm that the error was also logged at their end.

I also spent plenty of time searching for possible causes and trying various solutions none of which worked.

Sending was done using System.Net.Mail library and there was some suggestion in my research that this has some issues and is actually deprecated (there is some confusion over that though). Microsoft is recommending using an open-source library called MailKit instead.

So I decided to do some experimentation and rather than add any new dependencies I temporarily changed some of my code to use the outdated but believed to be more reliable System.Web.Mail library. The problem went away – no more errors!

Unfortunately System.Web.Mail couldn't easily do one thing I need to do (embedded images that don't also appear as attachments), so I opted to rewrite most of my mail sending code to use MailKit. MailKit can do all that System.Net.Mail and System.Web.Mail can do and more, and it's not hard to switch over to it.

There's been no further email errors with MailKit so I would suggest that you move away from System.Net.Mail if you ever face this error message.

Related Posts

Web Development

How to set up a debugging using the Turnkey Linux LAMP stack and VS Code

by johna | December 19, 2023
The second part in my guide to setting up a website and database using the Turnkey Linux LAMP stack.

Website Hosting Web Development

How to set up a website and database using the Turnkey Linux LAMP stack

by johna | November 18, 2023
If you need to host your own website for the purposes of web development, Turnkey Linux LAMP Stack is an easy to install all-in-one solution that you can set up on a spare computer or a VM (Virtual Machine).

Computers & Internet Web Development Website Hosting

500 Internal Server Error after migrating from IIS 7.5 to IIS 10

by johna | November 4, 2019
As support ends for Microsoft Windows Server 2008 I have recently gone through migrating some websites to a new server running Windows Server 2016 and IIS 10 but some of the websites did not work.

Comments

There are no comments yet. Be the first to leave a comment!

Leave a Comment

About

...random postings about web development and programming, Internet, computers and electronics topics.

I recommend ASPnix for web hosting and Crazy Domains for domain registration.

Subscribe

Get the latest posts delivered to your inbox.