Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b60b5e9
add IConnectionInherentKeepAliveFeature
analogrelay Nov 27, 2017
86940f9
crazy like a fox keep-alive impl
analogrelay Nov 27, 2017
cfb67e0
configure HubEndPoint to send ping frames if the connection is idle
analogrelay Nov 27, 2017
ae9572b
disable flaky docker tests :(
analogrelay Nov 27, 2017
9dad9c7
fix sockets sample
analogrelay Nov 27, 2017
0c043fb
clean up unused stuff
analogrelay Nov 27, 2017
56bb9d7
try something a little different
analogrelay Nov 28, 2017
3f2f83c
remove no-longer-needed KeepAliveChannel
analogrelay Nov 28, 2017
a46ed6f
spec update
analogrelay Nov 28, 2017
fcf4e4a
pr feedback
analogrelay Nov 28, 2017
7c86865
clean up options
analogrelay Nov 28, 2017
3a8ba54
pr feedback
analogrelay Nov 28, 2017
07650ec
pr feedback
analogrelay Nov 28, 2017
971e24e
trying something to make AppVeyor more reliable
analogrelay Nov 28, 2017
1d0c13d
untimeout the timeout timeout from timing out the timeout
analogrelay Nov 29, 2017
83943e9
use a single background timer per endpoint
analogrelay Nov 30, 2017
daf8c18
Move state to the HubConnectionContext
davidfowl Nov 30, 2017
7648a88
reworked after @davidfowl suggestions
analogrelay Nov 30, 2017
a001bf3
more clean-up; tests still broken
analogrelay Nov 30, 2017
21f57d1
fix test build
analogrelay Nov 30, 2017
499091c
stash test work
analogrelay Dec 1, 2017
6b08311
fix unit tests
analogrelay Dec 1, 2017
df6955c
Channels all the way down
davidfowl Dec 1, 2017
8bf06ec
integrate @davidfowl refactorings
analogrelay Dec 1, 2017
942aa7e
reposition IConnectionInherentKeepAliveFeature init
analogrelay Dec 1, 2017
c30064f
commit missed file
analogrelay Dec 1, 2017
c675be5
formatting
analogrelay Dec 1, 2017
5ee0774
pr feedback
analogrelay Dec 1, 2017
7e2012e
fix build
analogrelay Dec 3, 2017
68ac76c
pr feedback
analogrelay Dec 4, 2017
84f8279
derp
analogrelay Dec 4, 2017
60556d7
herpaderp
analogrelay Dec 4, 2017
477c4ce
fix builds
analogrelay Dec 4, 2017
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
20 changes: 9 additions & 11 deletions SignalR.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26923.0
VisualStudioVersion = 15.0.27110.0
MinimumVisualStudioVersion = 15.0.26730.03
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{DA69F624-5398-4884-87E4-B816698CDE65}"
ProjectSection(SolutionItems) = preProject
Expand Down Expand Up @@ -56,14 +56,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Signal
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SignalR.Client.TS", "client-ts\Microsoft.AspNetCore.SignalR.Client.TS\Microsoft.AspNetCore.SignalR.Client.TS.csproj", "{333526A4-633B-491A-AC45-CC62A0012D1C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{6CEC3DC2-5B01-45A8-8F0D-8531315DA90B}"
ProjectSection(SolutionItems) = preProject
test\Common\ChannelExtensions.cs = test\Common\ChannelExtensions.cs
test\Common\ServerFixture.cs = test\Common\ServerFixture.cs
test\Common\TaskExtensions.cs = test\Common\TaskExtensions.cs
test\Common\TestHelpers.cs = test\Common\TestHelpers.cs
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "client-ts", "client-ts", "{3A76C5A2-79ED-49BC-8BDC-6A3A766FFA1B}"
ProjectSection(SolutionItems) = preProject
client-ts\package.json = client-ts\package.json
Expand Down Expand Up @@ -91,7 +83,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Signal
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JwtSample", "samples\JwtSample\JwtSample.csproj", "{6A7491D3-3C97-49BD-A71C-433AED657F30}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JwtClientSample", "samples\JwtClientSample\JwtClientSample.csproj", "{1A953296-E869-4DE2-A693-FD5FCDE27057}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JwtClientSample", "samples\JwtClientSample\JwtClientSample.csproj", "{1A953296-E869-4DE2-A693-FD5FCDE27057}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.SignalR.Tests.Utils", "test\Microsoft.AspNetCore.SignalR.Tests.Utils\Microsoft.AspNetCore.SignalR.Tests.Utils.csproj", "{0A0A6135-EA24-4307-95C2-CE1B7E164A5E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -207,6 +201,10 @@ Global
{1A953296-E869-4DE2-A693-FD5FCDE27057}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1A953296-E869-4DE2-A693-FD5FCDE27057}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1A953296-E869-4DE2-A693-FD5FCDE27057}.Release|Any CPU.Build.0 = Release|Any CPU
{0A0A6135-EA24-4307-95C2-CE1B7E164A5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0A0A6135-EA24-4307-95C2-CE1B7E164A5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0A0A6135-EA24-4307-95C2-CE1B7E164A5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0A0A6135-EA24-4307-95C2-CE1B7E164A5E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -228,7 +226,6 @@ Global
{354335AB-CEE9-4434-A641-78058F6EFE56} = {DA69F624-5398-4884-87E4-B816698CDE65}
{455B68D2-C5B6-4BF4-A685-964B07AFAAF8} = {6A35B453-52EC-48AF-89CA-D4A69800F131}
{333526A4-633B-491A-AC45-CC62A0012D1C} = {3A76C5A2-79ED-49BC-8BDC-6A3A766FFA1B}
{6CEC3DC2-5B01-45A8-8F0D-8531315DA90B} = {6A35B453-52EC-48AF-89CA-D4A69800F131}
{96771B3F-4D18-41A7-A75B-FF38E76AAC89} = {8A4582C8-DC59-4B61-BCE7-119FBAA99EFB}
{75E342F6-5445-4E7E-9143-6D9AE62C2B1E} = {6A35B453-52EC-48AF-89CA-D4A69800F131}
{F2E4FBD6-9AEA-4A82-BAC9-3FAACA677DF8} = {DA69F624-5398-4884-87E4-B816698CDE65}
Expand All @@ -240,6 +237,7 @@ Global
{0B083AE6-86CA-4E0B-AE02-59154D1FD005} = {6A35B453-52EC-48AF-89CA-D4A69800F131}
{6A7491D3-3C97-49BD-A71C-433AED657F30} = {C4BC9889-B49F-41B6-806B-F84941B2549B}
{1A953296-E869-4DE2-A693-FD5FCDE27057} = {C4BC9889-B49F-41B6-806B-F84941B2549B}
{0A0A6135-EA24-4307-95C2-CE1B7E164A5E} = {6A35B453-52EC-48AF-89CA-D4A69800F131}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7945A4E4-ACDB-4F6E-95CA-6AC6E7C2CD59}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using Microsoft.AspNetCore.SignalR.Internal.Protocol;
using Microsoft.AspNetCore.Sockets;
using Microsoft.AspNetCore.Sockets.Internal;
using Microsoft.Extensions.Logging.Abstractions;

namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
{
Expand Down Expand Up @@ -32,7 +34,7 @@ public void GlobalSetup()
var transport = ChannelConnection.Create<byte[]>(input: transportToApplication, output: applicationToTransport);
var connection = new DefaultConnectionContext(Guid.NewGuid().ToString(), transport, application);

_hubLifetimeManager.OnConnectedAsync(new HubConnectionContext(Channel.CreateUnbounded<HubMessage>(), connection)).Wait();
_hubLifetimeManager.OnConnectedAsync(new HubConnectionContext(connection, Timeout.InfiniteTimeSpan, NullLoggerFactory.Instance)).Wait();
}

_hubContext = new HubContext<Hub>(_hubLifetimeManager);
Expand Down
28 changes: 14 additions & 14 deletions client-ts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion samples/SocketsSample/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
Expand All @@ -17,7 +18,11 @@ public void ConfigureServices(IServiceCollection services)
{
services.AddSockets();

services.AddSignalR();
services.AddSignalR(options =>
{
// Faster pings for testing
options.KeepAliveInterval = TimeSpan.FromSeconds(5);
});
// .AddRedis();

services.AddCors(o =>
Expand Down
2 changes: 1 addition & 1 deletion samples/SocketsSample/wwwroot/hubs.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
Expand Down
4 changes: 2 additions & 2 deletions samples/SocketsSample/wwwroot/sockets.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
Expand Down Expand Up @@ -31,7 +31,7 @@ <h1 id="transportName">Unknown Transport</h1>
document.getElementById('transportName').innerHTML = signalR.TransportType[transportType];

let url = 'http://' + document.location.host + '/chat';
let connection = new signalR.HttpConnection(url, { transport: transportType, logger: new signalR.ConsoleLogger(signalR.LogLevel.Information) });
let connection = new signalR.HttpConnection(url, { transport: transportType, logging: new signalR.ConsoleLogger(signalR.LogLevel.Information) });

connection.onreceive = function(data) {
let child = document.createElement('li');
Expand Down
4 changes: 2 additions & 2 deletions samples/SocketsSample/wwwroot/streaming.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
Expand Down Expand Up @@ -65,7 +65,7 @@ <h2>Results</h2>
});

click('connectButton', function () {
connection = new signalR.HubConnection('/streaming', { transport: transportType, logger: logger });
connection = new signalR.HubConnection('/streaming', { transport: transportType, logging: logger });

connection.onclose(function () {
channelButton.disabled = true;
Expand Down
2 changes: 2 additions & 0 deletions specs/HubProtocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ Keep alive behavior is achieved via the `Ping` message type. **Either endpoint**

Ping messages do not have any payload, they are completely empty messages (aside from the encoding necessary to identify the message as a `Ping` message).

It is up to the server implementation to decide how frequently (if at all) `Ping` frames are sent. The ASP.NET Core implementation sends `Ping` frames only when using the Server Sent Events and WebSockets transports, at a default interval of 15 seconds (configurable). However, a `Ping` frame is only sent if 15 seconds elapses since the last message was sent. Clients may choose to use the "Ping rate" to provide a timeout for the server connection. Since the Client can expect the server to send `Ping` frames at regular intervals, even when the connection is idle, it can use that to determine if the server has left without closing the connection. The ASP.NET Core implementation (both JavaScript and C#) use a default timeout window of 30 seconds, which is twice the server ping rate interval.

## Example

Consider the following C# methods
Expand Down
19 changes: 4 additions & 15 deletions src/Microsoft.AspNetCore.SignalR.Core/DefaultHubLifetimeManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
Expand Down Expand Up @@ -86,7 +86,7 @@ private Task InvokeAllWhere(string methodName, object[] args, Func<HubConnection
continue;
}

tasks.Add(WriteAsync(connection, message));
tasks.Add(connection.WriteAsync(message));
}

return Task.WhenAll(tasks);
Expand All @@ -108,7 +108,7 @@ public override Task InvokeConnectionAsync(string connectionId, string methodNam

var message = CreateInvocationMessage(methodName, args);

return WriteAsync(connection, message);
return connection.WriteAsync(message);
}

public override Task InvokeGroupAsync(string groupName, string methodName, object[] args)
Expand All @@ -122,7 +122,7 @@ public override Task InvokeGroupAsync(string groupName, string methodName, objec
if (group != null)
{
var message = CreateInvocationMessage(methodName, args);
var tasks = group.Values.Select(c => WriteAsync(c, message));
var tasks = group.Values.Select(c => c.WriteAsync(message));
return Task.WhenAll(tasks);
}

Expand Down Expand Up @@ -153,17 +153,6 @@ public override Task OnDisconnectedAsync(HubConnectionContext connection)
return Task.CompletedTask;
}

private async Task WriteAsync(HubConnectionContext connection, HubInvocationMessage hubMessage)
{
while (await connection.Output.WaitToWriteAsync())
{
if (connection.Output.TryWrite(hubMessage))
{
break;
}
}
}

private string GetInvocationId()
{
var invocationId = Interlocked.Increment(ref _nextInvocationId);
Expand Down
17 changes: 0 additions & 17 deletions src/Microsoft.AspNetCore.SignalR.Core/Features/IHubFeature.cs

This file was deleted.

Loading