1

Resolved

can't get smtp server to cleanly stop

description

I am using VS2008 unit tests to verify that my code can send emails using System.Net.SmtpClient and RnWood.SmtpServer. The unit test starts up the smtp server on localhost then successfully runs one test. Each send test reads the message data so the test can assert the subject/body/recipients were done properly. Once each tests completes, the smtp server is stopped and the next test is started. This is where things go a muck.
For some reason when the smtp server is stopped there is still a connection with a blocking IO operation pending here:
 
public string ReadLine()
    {
        string text = _reader.ReadLine();  //blocking IO operation here
        Session.AppendToLog(text);
        return text;
    }
 
So we never get a clean shutdown of the smtp server and test host. Subsequent unit tests fail with bizarre "Failed to acquire a WriterLock" from the Unit Test Host.

comments

rnwood wrote Jun 17, 2010 at 7:35 AM

Thanks for reporting this issue.
As you've noted stopping the server currently does not handle shutting down the worker threads. This is something I'd like to address and will look and will post a fix for shortly.

wrote Aug 18, 2011 at 6:03 AM

wrote Feb 13, 2013 at 11:41 PM

wrote May 16, 2013 at 4:02 AM

wrote May 16, 2013 at 4:02 AM

wrote Jun 14, 2013 at 7:43 AM