I have WebApi and a c# client application. In order to run integration tests, I use owin self host in a base class like this:
Namespace IntegrationTest {
  [SetUpFixture]
  Public Class ServerManager {
    Privet Static IDisposable server;
    [SetUp]
    Protected Static Void StartAPI() {
      server = WebApp.Start<Startup>.("Https://localhost:8080");
      LogIn();
    }
    Public Static Void LogIn() {
      Clientdll.Login(*some Parma's);
    }
   [TearDown]
   Protected Static Void Shutdown API() {
     LogOut();
     server.Dispose();
   }
 }
}
All the test passes locally in my computer like others computers thet take the code from the TFS server, but when I run the tests in team city, its fails and shows this exception: ---> System.Net.Http.HttpRequestExeption : An error occurred while sending the request.
---> System. Net.WebExeption : The underlying connection was closed: An unexpected error occurred on a send.
System. IO.IOExepyion : unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System. Net.Socket.SocketExeption : An exciting connection was forcibly closed by the remote host.
 
     
    