Intermittent "Unable to read data from the transport connection: net_io_connectionclosed" errors
by johna | 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
Converting dBase IV programs to run in the browser
by johna | September 13, 2024
Some pointless entertainment trying to get some old dBase programs running in the browser.
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.
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).
Comments
There are no comments yet. Be the first to leave a comment!