diff --git a/build/setup-wstest.sh b/build/setup-wstest.sh
index 2fb19c5bf3cd7ff896cf0a261f80ff4f220209c4..11056f927a9792dd69ce948f95a59fa90e44390f 100755
--- a/build/setup-wstest.sh
+++ b/build/setup-wstest.sh
@@ -6,18 +6,24 @@ if [ "$TRAVIS_OS_NAME" == "osx" ]; then
     brew install python
 fi
 
-type -p python
-python --version
+PYTHON_CMD=python
+if type -p python2.7 > /dev/null; then
+    echo "Using 'python2.7' executable because it's available."
+    PYTHON_CMD=python2.7
+fi
+
+$PYTHON_CMD --version
 
 # Install local virtualenv
 mkdir .python
 cd .python
-curl -O https://pypi.python.org/packages/d4/0c/9840c08189e030873387a73b90ada981885010dd9aea134d6de30cd24cb8/virtualenv-15.1.0.tar.gz
+curl -OL https://pypi.python.org/packages/d4/0c/9840c08189e030873387a73b90ada981885010dd9aea134d6de30cd24cb8/virtualenv-15.1.0.tar.gz
+
 tar xf virtualenv-15.1.0.tar.gz
 cd ..
 
 # Make a virtualenv
-python ./.python/virtualenv-15.1.0/virtualenv.py .virtualenv
+$PYTHON_CMD ./.python/virtualenv-15.1.0/virtualenv.py .virtualenv
 
 .virtualenv/bin/python --version
 .virtualenv/bin/pip --version
@@ -27,4 +33,4 @@ python ./.python/virtualenv-15.1.0/virtualenv.py .virtualenv
 
 # We're done. The travis config has already established the path to WSTest should be within the virtualenv.
 ls -l .virtualenv/bin
-.virtualenv/bin/wstest --version
\ No newline at end of file
+.virtualenv/bin/wstest --version
diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs b/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs
index 77ec387c1014d78d0fd9930ea4705eaf6534080b..5a1b988d0ac03cf9ef5dbd2b11606f447f709a06 100644
--- a/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs
+++ b/test/Microsoft.AspNetCore.WebSockets.Test/KestrelWebSocketHelpers.cs
@@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test
 {
     public class KestrelWebSocketHelpers
     {
-        public static IDisposable CreateServer(ILoggerFactory loggerFactory, Func<HttpContext, Task> app)
+        public static IDisposable CreateServer(ILoggerFactory loggerFactory, Func<HttpContext, Task> app, int port)
         {
             Action<IApplicationBuilder> startup = builder =>
             {
@@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.WebSockets.Test
             var configBuilder = new ConfigurationBuilder();
             configBuilder.AddInMemoryCollection();
             var config = configBuilder.Build();
-            config["server.urls"] = "http://localhost:54321";
+            config["server.urls"] = $"http://localhost:{port}";
 
             var host = new WebHostBuilder()
                 .ConfigureServices(s => s.AddSingleton(loggerFactory))
diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj
index 5e7f2eb67e20517b207d1a7fdb01e710595fbd25..c906aa0f91d34af85ab5cd5b07aac5bee0e6bd15 100644
--- a/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj
+++ b/test/Microsoft.AspNetCore.WebSockets.Test/Microsoft.AspNetCore.WebSockets.Test.csproj
@@ -10,6 +10,7 @@
 
   <ItemGroup>
     <PackageReference Include="Microsoft.Extensions.Logging.Testing" Version="$(MicrosoftExtensionsLoggingTestingPackageVersion)" />
+    <PackageReference Include="Microsoft.AspNetCore.Server.IntegrationTesting" Version="$(MicrosoftAspNetCoreServerIntegrationTestingPackageVersion)" />
     <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(MicrosoftAspNetCoreServerKestrelPackageVersion)" />
     <PackageReference Include="Microsoft.AspNetCore.Testing" Version="$(MicrosoftAspNetCoreTestingPackageVersion)" />
     <PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
diff --git a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs
index e966aea6b45d98db37dbf5feda485cede43c9aac..c976a69cec42c2ccd1649b9d12dd4fbe7e00647a 100644
--- a/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs
+++ b/test/Microsoft.AspNetCore.WebSockets.Test/WebSocketMiddlewareTests.cs
@@ -6,6 +6,7 @@ using System.Net.WebSockets;
 using System.Text;
 using System.Threading;
 using System.Threading.Tasks;
+using Microsoft.AspNetCore.Server.IntegrationTesting.Common;
 using Microsoft.AspNetCore.Testing.xunit;
 using Microsoft.Extensions.Logging.Testing;
 using Xunit;
@@ -23,10 +24,13 @@ namespace Microsoft.AspNetCore.WebSockets.Test
 #endif
     public class WebSocketMiddlewareTests : LoggedTest
     {
-        private static string ClientAddress = "ws://localhost:54321/";
+        private readonly int Port;
+        private readonly string Address;
 
         public WebSocketMiddlewareTests(ITestOutputHelper output) : base(output)
         {
+            Port = TestUriHelper.GetNextPort();
+            Address = $"ws://localhost:{Port}/";
         }
 
         [ConditionalFact]
@@ -38,11 +42,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test
                 {
                     Assert.True(context.WebSockets.IsWebSocketRequest);
                     var webSocket = await context.WebSockets.AcceptWebSocketAsync();
-                }))
+                },
+                Port))
                 {
                     using (var client = new ClientWebSocket())
                     {
-                        await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None);
+                        await client.ConnectAsync(new Uri(Address), CancellationToken.None);
                     }
                 }
             }
@@ -58,14 +63,15 @@ namespace Microsoft.AspNetCore.WebSockets.Test
                     Assert.True(context.WebSockets.IsWebSocketRequest);
                     Assert.Equal("alpha, bravo, charlie", context.Request.Headers["Sec-WebSocket-Protocol"]);
                     var webSocket = await context.WebSockets.AcceptWebSocketAsync("Bravo");
-                }))
+                },
+                Port))
                 {
                     using (var client = new ClientWebSocket())
                     {
                         client.Options.AddSubProtocol("alpha");
                         client.Options.AddSubProtocol("bravo");
                         client.Options.AddSubProtocol("charlie");
-                        await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None);
+                        await client.ConnectAsync(new Uri(Address), CancellationToken.None);
 
                         // The Windows version of ClientWebSocket uses the casing from the header (Bravo)
                         // However, the Managed version seems match the header against the list generated by
@@ -94,11 +100,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test
                     Assert.True(result.EndOfMessage);
                     Assert.Equal(0, result.Count);
                     Assert.Equal(WebSocketMessageType.Binary, result.MessageType);
-                }))
+                },
+                Port))
                 {
                     using (var client = new ClientWebSocket())
                     {
-                        await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None);
+                        await client.ConnectAsync(new Uri(Address), CancellationToken.None);
                         var orriginalData = new byte[0];
                         await client.SendAsync(new ArraySegment<byte>(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None);
                     }
@@ -123,11 +130,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test
                     Assert.Equal(orriginalData.Length, result.Count);
                     Assert.Equal(WebSocketMessageType.Binary, result.MessageType);
                     Assert.Equal(orriginalData, serverBuffer);
-                }))
+                },
+                Port))
                 {
                     using (var client = new ClientWebSocket())
                     {
-                        await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None);
+                        await client.ConnectAsync(new Uri(Address), CancellationToken.None);
                         await client.SendAsync(new ArraySegment<byte>(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None);
                     }
                 }
@@ -151,11 +159,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test
                     Assert.Equal(orriginalData.Length, result.Count);
                     Assert.Equal(WebSocketMessageType.Binary, result.MessageType);
                     Assert.Equal(orriginalData, serverBuffer);
-                }))
+                },
+                Port))
                 {
                     using (var client = new ClientWebSocket())
                     {
-                        await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None);
+                        await client.ConnectAsync(new Uri(Address), CancellationToken.None);
                         await client.SendAsync(new ArraySegment<byte>(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None);
                     }
                 }
@@ -191,11 +200,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test
                     Assert.Equal(WebSocketMessageType.Text, result.MessageType);
 
                     Assert.Equal(orriginalData, serverBuffer);
-                }))
+                },
+                Port))
                 {
                     using (var client = new ClientWebSocket())
                     {
-                        await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None);
+                        await client.ConnectAsync(new Uri(Address), CancellationToken.None);
                         await client.SendAsync(new ArraySegment<byte>(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None);
                     }
                 }
@@ -235,11 +245,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test
                     Assert.Equal(WebSocketMessageType.Binary, result.MessageType);
 
                     Assert.Equal(orriginalData, serverBuffer);
-                }))
+                },
+                Port))
                 {
                     using (var client = new ClientWebSocket())
                     {
-                        await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None);
+                        await client.ConnectAsync(new Uri(Address), CancellationToken.None);
                         await client.SendAsync(new ArraySegment<byte>(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None);
                         await client.SendAsync(new ArraySegment<byte>(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None);
                         await client.SendAsync(new ArraySegment<byte>(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None);
@@ -260,11 +271,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test
                     var webSocket = await context.WebSockets.AcceptWebSocketAsync();
 
                     await webSocket.SendAsync(new ArraySegment<byte>(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None);
-                }))
+                },
+                Port))
                 {
                     using (var client = new ClientWebSocket())
                     {
-                        await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None);
+                        await client.ConnectAsync(new Uri(Address), CancellationToken.None);
                         var clientBuffer = new byte[orriginalData.Length];
                         var result = await client.ReceiveAsync(new ArraySegment<byte>(clientBuffer), CancellationToken.None);
                         Assert.True(result.EndOfMessage);
@@ -288,11 +300,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test
                     var webSocket = await context.WebSockets.AcceptWebSocketAsync();
 
                     await webSocket.SendAsync(new ArraySegment<byte>(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None);
-                }))
+                },
+                Port))
                 {
                     using (var client = new ClientWebSocket())
                     {
-                        await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None);
+                        await client.ConnectAsync(new Uri(Address), CancellationToken.None);
                         var clientBuffer = new byte[orriginalData.Length];
                         var result = await client.ReceiveAsync(new ArraySegment<byte>(clientBuffer), CancellationToken.None);
                         Assert.True(result.EndOfMessage);
@@ -316,11 +329,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test
                     var webSocket = await context.WebSockets.AcceptWebSocketAsync();
 
                     await webSocket.SendAsync(new ArraySegment<byte>(orriginalData), WebSocketMessageType.Binary, true, CancellationToken.None);
-                }))
+                },
+                Port))
                 {
                     using (var client = new ClientWebSocket())
                     {
-                        await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None);
+                        await client.ConnectAsync(new Uri(Address), CancellationToken.None);
                         var clientBuffer = new byte[orriginalData.Length];
                         WebSocketReceiveResult result;
                         int receivedCount = 0;
@@ -354,11 +368,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test
                     await webSocket.SendAsync(new ArraySegment<byte>(orriginalData, 0, 2), WebSocketMessageType.Binary, false, CancellationToken.None);
                     await webSocket.SendAsync(new ArraySegment<byte>(orriginalData, 2, 2), WebSocketMessageType.Binary, false, CancellationToken.None);
                     await webSocket.SendAsync(new ArraySegment<byte>(orriginalData, 4, 7), WebSocketMessageType.Binary, true, CancellationToken.None);
-                }))
+                },
+                Port))
                 {
                     using (var client = new ClientWebSocket())
                     {
-                        await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None);
+                        await client.ConnectAsync(new Uri(Address), CancellationToken.None);
                         var clientBuffer = new byte[orriginalData.Length];
                         var result = await client.ReceiveAsync(new ArraySegment<byte>(clientBuffer), CancellationToken.None);
                         Assert.False(result.EndOfMessage);
@@ -404,11 +419,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test
                     Assert.Equal(WebSocketMessageType.Close, result.MessageType);
                     Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus);
                     Assert.Equal(closeDescription, result.CloseStatusDescription);
-                }))
+                },
+                Port))
                 {
                     using (var client = new ClientWebSocket())
                     {
-                        await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None);
+                        await client.ConnectAsync(new Uri(Address), CancellationToken.None);
                         await client.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None);
 
                         Assert.Equal(WebSocketState.CloseSent, client.State);
@@ -429,11 +445,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test
                     var webSocket = await context.WebSockets.AcceptWebSocketAsync();
 
                     await webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None);
-                }))
+                },
+                Port))
                 {
                     using (var client = new ClientWebSocket())
                     {
-                        await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None);
+                        await client.ConnectAsync(new Uri(Address), CancellationToken.None);
                         var clientBuffer = new byte[1024];
                         var result = await client.ReceiveAsync(new ArraySegment<byte>(clientBuffer), CancellationToken.None);
                         Assert.True(result.EndOfMessage);
@@ -468,11 +485,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test
                     Assert.Equal(closeDescription, result.CloseStatusDescription);
 
                     await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None);
-                }))
+                },
+                Port))
                 {
                     using (var client = new ClientWebSocket())
                     {
-                        await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None);
+                        await client.ConnectAsync(new Uri(Address), CancellationToken.None);
                         await client.CloseAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None);
 
                         Assert.Equal(WebSocketState.Closed, client.State);
@@ -501,11 +519,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test
                     Assert.Equal(closeDescription, result.CloseStatusDescription);
 
                     await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None);
-                }))
+                },
+                Port))
                 {
                     using (var client = new ClientWebSocket())
                     {
-                        await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None);
+                        await client.ConnectAsync(new Uri(Address), CancellationToken.None);
                         await client.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeDescription, CancellationToken.None);
                         Assert.Equal(WebSocketState.CloseSent, client.State);
 
@@ -536,11 +555,12 @@ namespace Microsoft.AspNetCore.WebSockets.Test
                     Assert.Equal(WebSocketMessageType.Close, result.MessageType);
                     Assert.Equal(WebSocketCloseStatus.NormalClosure, result.CloseStatus);
                     Assert.Equal(closeDescription, result.CloseStatusDescription);
-                }))
+                },
+                Port))
                 {
                     using (var client = new ClientWebSocket())
                     {
-                        await client.ConnectAsync(new Uri(ClientAddress), CancellationToken.None);
+                        await client.ConnectAsync(new Uri(Address), CancellationToken.None);
                         var clientBuffer = new byte[1024];
                         var result = await client.ReceiveAsync(new ArraySegment<byte>(clientBuffer), CancellationToken.None);
                         Assert.True(result.EndOfMessage);