public async Task Issue_109()
        {
            var port = PortManager.GetNextPort();

            var server = new Server()
            {
                Ports = { new ServerPort("localhost", port, ServerCredentials.Insecure) }
            };
            // it seems that the port is already in use at this point

            // try all kinds of ways to release the port
            await server.ShutdownAsync();

            // await server.KillAsync(); // kill also doesn't release, but can't Shutdown *and* Kill
            await server.ShutdownTask;

            var server2 = new Server()
            {
                Ports = { new ServerPort("localhost", port, ServerCredentials.Insecure) }
            };

            // server2.Services.Add(...) // note: repros even without any services
            server2.Start(); // <--- crash, socket is still in use.
        }
Example #2
0
 public static int GetNextPort()
 {
     return(PortManager.GetNextPort());
 }