Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ public class DeferredDisconnectTests
{
private static readonly TimeSpan Patience = TimeSpan.FromSeconds(5);

[TestMethod]
public void DisconnectOnEmptyChannelsAfter_ShouldBeTwiceTheHeartbeatInterval_GivenDefaultOptions()
{
var options = new ClientOptions();
options.DisconnectOnEmptyChannelsAfter.Should().Be(2 * options.HeartbeatInterval, "an idle socket must close by default");
}

[TestMethod]
public async Task Unsubscribe_ShouldDisconnect_GivenTheLastChannelClosed()
{
Expand Down
8 changes: 4 additions & 4 deletions packages/Realtime/Realtime/ClientOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ public class ClientOptions
public TimeSpan ProbeTimeout { get; set; } = TimeSpan.FromSeconds(5);

/// <summary>
/// When set, the socket disconnects once the last channel has been closed for this long, and the next
/// <c>Subscribe</c> connects again. Left null, the socket stays open.
/// The socket disconnects once the last channel has been closed for this long, and the next <c>Subscribe</c>
/// connects again. Defaults to 40 seconds, twice the default heartbeat interval. Set to null to keep the socket open.
/// </summary>
[PartialCapability("realtime.configuration.deferred_disconnect", "Opt-in: null by default, so the socket stays open. Closing an idle socket by default is a breaking change planned for 9.0.0.")]
public TimeSpan? DisconnectOnEmptyChannelsAfter { get; set; }
[ImplementedCapability("realtime.configuration.deferred_disconnect")]
public TimeSpan? DisconnectOnEmptyChannelsAfter { get; set; } = TimeSpan.FromSeconds(40);

/// <summary>
/// The delay before the next reconnect attempt after one failed, given the attempt number starting at 1. Defaults
Expand Down