public override bool Execute() { try { var myHost = new IISExpressTestHost(HostLocation[0].ToString()); myHost.Initialize(keepAlive: 2, connectionTimeout: 120, disconnectTimeout: 10, hearbeatInterval: 1, enableAutoRejoiningGroups: false); } catch (WebException ex) { var response = ex.Response; if (response == null) { Log.LogError(ex.ToString()); throw; } using (response) { using (var sr = new StreamReader(response.GetResponseStream())) { Log.LogError(sr.ReadToEnd()); throw; } } } catch (Exception ex) { Log.LogError(ex.ToString()); throw; } return true; }
public void FallbackToLongPollingIIS() { using (ITestHost host = new IISExpressTestHost()) { host.Initialize(); var connection = CreateConnection(host.Url + "/fall-back"); var tcs = new TaskCompletionSource<object>(); connection.StateChanged += change => { if (change.NewState == ConnectionState.Reconnecting) { tcs.TrySetException(new Exception("The connection should not be reconnecting")); } }; var client = new DefaultHttpClient(); var transports = new IClientTransport[] { new ServerSentEventsTransport(client) { ConnectionTimeout = TimeSpan.Zero }, new LongPollingTransport(client) }; var transport = new AutoTransport(client, transports); connection.Start(transport).Wait(); Assert.Equal(connection.Transport.Name, "longPolling"); Assert.False(tcs.Task.Wait(TimeSpan.FromSeconds(5))); connection.Stop(); } }