Skip to content

Commit

Permalink
Disabled keep alive for LP
Browse files Browse the repository at this point in the history
  • Loading branch information
abnanda1 committed Jun 7, 2013
1 parent 74760cb commit 9a7e073
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Microsoft.AspNet.SignalR.Client/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ private Task StartTransport(string data)
_connectingMessageBuffer.Drain();
}
if (_keepAliveData != null)
if (_keepAliveData != null && _transport.SupportsKeepAlive)
{
// Start the monitor to check for server activity
_monitor.Start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,37 @@ public void OnConnectionSlowTest(HostType hostType, TransportType transportType,
}
}
}

[Theory]
[InlineData(HostType.IISExpress, TransportType.LongPolling)]
[InlineData(HostType.Memory, TransportType.LongPolling)]
public void OnConnectionSlowDoesntFireForLongPolling(HostType hostType, TransportType transportType)
{
using (var host = CreateHost(hostType, transportType))
{
// Arrange
var mre = new ManualResetEventSlim();
host.Initialize(keepAlive: 2);
var connection = CreateConnection(host, "/my-reconnect");

using (connection)
{
((Client.IConnection)connection).KeepAliveData = new KeepAliveData(TimeSpan.FromSeconds(2));

connection.ConnectionSlow += () =>
{
mre.Set();
};

connection.Start(host.Transport).Wait();

// Assert
Assert.False(mre.Wait(TimeSpan.FromSeconds(10)));

// Clean-up
mre.Dispose();
}
}
}
}
}

0 comments on commit 9a7e073

Please sign in to comment.