Git Product home page Git Product logo

signalr's Introduction

ASP.NET Core SignalR [Archived]

This GitHub project has been archived. Ongoing development on this project can be found in https://github.com/aspnet/AspNetCore.

IMPORTANT: This repository hosts code and project management for ASP.NET Core SignalR, for use in ASP.NET Core applications using Microsoft.AspNetCore.App. If you are looking for information on ASP.NET SignalR (used in .NET Framework applications using System.Web and/or Katana), see the https://github.com/SignalR/SignalR repository.

ASP.NET Core SignalR is a new library for ASP.NET Core developers that makes it incredibly simple to add real-time web functionality to your applications. What is "real-time web" functionality? It's the ability to have your server-side code push content to the connected clients as it happens, in real-time.

You can watch an introductory presentation here - ASP.NET Core SignalR: Build 2018

This project is part of ASP.NET Core. You can find samples, documentation and getting started instructions for ASP.NET Core at the Home repo.

Documentation

Documentation for ASP.NET Core SignalR can be found in the Real-time Apps section of the ASP.NET Core Documentation site.

TypeScript Version

If you are encountering TypeScript definition issues with SignalR, please ensure you are using the latest version of TypeScript to compile your application. If the issue occurs in the latest TypeScript, please let us know.

When in doubt, check the version of TypeScript referenced by our package.json file. That version is the minimum TypeScript version expected to work with SignalR.

Packages

You can install the latest released JavaScript client from npm with the following command:

npm install @aspnet/signalr

The @aspnet/signalr package (and it's dependencies) require NPM 5.6.0 or higher.

NOTE: Previous previews of the SignalR client library for JavaScript were named @aspnet/signalr-client. This has been deprecated as of Preview 1.

IMPORTANT: When using preview builds, you should always ensure you are using the same version of both the JavaScript client and the Server. The version numbers should align as they are produced in the same build process.

The CI build publishes the latest dev version of the JavaScript client to our dev npm registry as @aspnet/signalr. You can install the module as follows:

  • Create an .npmrc file with the following line: @aspnet:registry=https://dotnet.myget.org/f/aspnetcore-dev/npm/
  • Run: npm install @aspnet/signalr

Alternatively, if you don't want to create the .npmrc file run the following commands:

npm install @aspnet/signalr --registry https://dotnet.myget.org/f/aspnetcore-dev/npm/

We also have a MsgPack protocol library which is installed via:

npm install @aspnet/signalr-protocol-msgpack

Deploying

Once you've installed the NPM modules, they will be located in the node_modules/@aspnet/signalr and node_modules/@aspnet/signalr-protocol-msgpack folders. If you are building a NodeJS application or using an ECMAScript module loader/bundler (such as webpack), you can load them directly. If you are building a browser application without using a module bundler, you can find UMD-compatible bundles in the dist/browser folder; minified versions are provided as well. Simply copy these to your project as appropriate and use a build task to keep them up-to-date.

Building from source

To run a complete build on command line only, execute build.cmd or build.sh without arguments.

If this is your first time building SignalR please see the Getting Started for more information about project dependencies and other build-related information specific to SignalR.

See developer documentation for general information on building and contributing to this and other aspnet repositories.

signalr's People

Contributors

ahsonkhan avatar ajaybhargavb avatar analogrelay avatar aspnetci avatar benaadams avatar brennanconroy avatar damianedwards avatar davidfowl avatar dotnet-maestro-bot avatar drawaes avatar dylandmitri avatar eilon avatar gurgen avatar halter73 avatar haok avatar herecydev avatar jamesnk avatar juntaoluo avatar kichalla avatar mikaelm12 avatar mikeharder avatar moozzyk avatar natemcmaster avatar ntaylormullen avatar olofd avatar pakrym avatar pranavkm avatar ryanbrandenburg avatar tragetaschen avatar tratcher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

signalr's Issues

Long polling transport on the client sends polls even if it is supposed to be closed

Enable logging when running functional tests and you often get this:

dbug: Microsoft.AspNetCore.Hosting.Internal.WebHost[5]
      Hosting shutdown
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
      Request finished in 2.1319ms 200
  Finished:    Microsoft.AspNetCore.SignalR.Client.FunctionalTests
fail: Microsoft.AspNetCore.Sockets.Client.LongPollingTransport[0]
      Error while polling 'http://test/hubs/poll?id=b9f56cdf-6b85-4977-a761-fe67de69f46f': System.ObjectDisposedException: Cannot access a disposed object.
      Object name: 'Microsoft.AspNetCore.TestHost.TestServer'.
         at Microsoft.AspNetCore.TestHost.TestServer.<Microsoft.AspNetCore.Hosting.Server.IServer.Start>b__20_0[TContext]()
         at Microsoft.AspNetCore.TestHost.TestServer.ApplicationWrapper`1.ProcessRequestAsync(TContext context)
         at Microsoft.AspNetCore.TestHost.ClientHandler.<>c__DisplayClass3_0.<<SendAsync>b__0>d.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
         at Microsoft.AspNetCore.TestHost.ClientHandler.<SendAsync>d__3.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
         at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
         at System.Net.Http.HttpClient.<FinishSendAsync>d__58.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
         at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
         at Microsoft.AspNetCore.Sockets.Client.LongPollingTransport.<Poll>d__16.MoveNext() in C:\source\SignalR-Core\src\Microsoft.AspNetCore.Sockets.Client\LongPollingTransport.cs:line 70

It won't fail the test because the test is already completed but

HubProxy.Subscribe is not thread safe

Expected behavior

HubProxt.Subscribe(eventName) should be thread safe, according to documentation here:
https://www.asp.net/signalr/overview/guide-to-the-api/hubs-api-guide-net-client
And here:
http://stackoverflow.com/questions/16089876/signalr-hubproxy-invoke-thread-safety

(However, it's stated to be non-thread safe here:
https://msdn.microsoft.com/en-us/library/microsoft.aspnet.signalr.client.hubs.hubproxy(v=vs.111).aspx)

Actual behavior

HubProxy.Subscribe() accesses the _subscriptions list in a non-thread safe manner. This causes data to be sent to the wrong onData callback.

Steps to reproduce

If you call IHubProxy.On(eventName, onData) (which in turn calls HubProxy.Subscribe) lots of times from different threads at the same time, data from one event may be delivered to another onData callback.
Adding a lock around the On() call prevents the issue.

Connection Establishment Semantics

Rename /getid to /negotiate and have it establish the connection metadata and state (including allocating the Channel/Pipeline). We will still support a raw WebSocket connection, which will lazily initialize the connection state, but Server-sent Events and Long Polling will require that the connection be established before working. This should eliminate the Send/Poll race referred to in #82.

tsc command error

I cant compile the sample projects for some reason MSBuild cant find the typescript compiler. I have the typescript compiler installed from the readme but I still get these errors when compiling.

No executable found matching command "tsc" - Microsoft.DotNet.Common.Targets

for both the ChatSample and SocketsSample

possible System.* v 4.0.1 and v4.2 dependency issue upon adding signalr v1.* to project.json

using 1.2.0-* netcoreapp1.2 adding "Microsoft.AspNetCore.SignalR": "1.0.0-*" causes dependency ambiguity issues with type
Task<TResult>

Error	CS0433	The type 'Task<TResult>' exists in both 'System.Threading.Tasks, Version=4.0.10.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.Runtime, Version=4.2.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'	ds.air..NETCoreApp,Version=v1.2

I have tried digging for this issue for about a week, and have narrowed down to possible package dependencies (although this is speculation here)
Newtonsoft.json <9.0.1

Socket Got Closed

After web socket connection started and Socket is open, I try to send a message to chat Hub but the connection get closed automatically and this is the full error message :

info: Microsoft.AspNetCore.Sockets.WebSockets[0]
      Socket closed.
Microsoft.AspNetCore.Sockets.WebSockets:Information: Socket closed.
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[0]
      An unhandled exception has occurred while executing the request
System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.AspNetCore.SignalR.JsonNetInvocationAdapter.<>c__DisplayClass2_0.<ReadInvocationDescriptorAsync>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.SignalR.HubEndPoint`2.<DispatchMessagesAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.SignalR.HubEndPoint`2.<OnConnectedAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.SignalR.HubEndPoint`2.<OnConnectedAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Sockets.HttpConnectionDispatcher.<DoPersistentConnection>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Sockets.HttpConnectionDispatcher.<ExecuteAsync>d__4`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext()
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware:Error: An unhandled exception has occurred while executing the request

System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.AspNetCore.SignalR.JsonNetInvocationAdapter.<>c__DisplayClass2_0.<ReadInvocationDescriptorAsync>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.SignalR.HubEndPoint`2.<DispatchMessagesAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.SignalR.HubEndPoint`2.<OnConnectedAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.SignalR.HubEndPoint`2.<OnConnectedAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Sockets.HttpConnectionDispatcher.<DoPersistentConnection>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Sockets.HttpConnectionDispatcher.<ExecuteAsync>d__4`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext()
warn: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[0]
      The response has already started, the error page middleware will not be executed.
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware:Warning: The response has already started, the error page middleware will not be executed.
fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HL0UF3B8F88B": An unhandled exception was thrown by the application.
System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.AspNetCore.SignalR.JsonNetInvocationAdapter.<>c__DisplayClass2_0.<ReadInvocationDescriptorAsync>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.SignalR.HubEndPoint`2.<DispatchMessagesAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.SignalR.HubEndPoint`2.<OnConnectedAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.SignalR.HubEndPoint`2.<OnConnectedAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Sockets.HttpConnectionDispatcher.<DoPersistentConnection>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Sockets.HttpConnectionDispatcher.<ExecuteAsync>d__4`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware.<Invoke>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Frame`1.<RequestProcessingAsync>d__2.MoveNext()
Microsoft.AspNetCore.Server.Kestrel:Error: Connection id "0HL0UF3B8F88B": An unhandled exception was thrown by the application.

System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.AspNetCore.SignalR.JsonNetInvocationAdapter.<>c__DisplayClass2_0.<ReadInvocationDescriptorAsync>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.SignalR.HubEndPoint`2.<DispatchMessagesAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.SignalR.HubEndPoint`2.<OnConnectedAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.SignalR.HubEndPoint`2.<OnConnectedAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Sockets.HttpConnectionDispatcher.<DoPersistentConnection>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Sockets.HttpConnectionDispatcher.<ExecuteAsync>d__4`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware.<Invoke>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Frame`1.<RequestProcessingAsync>d__2.MoveNext()
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
      Request finished in 7818.7469ms 101 
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request finished in 7818.7469ms 101 
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/  
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request starting HTTP/1.1 GET http://localhost:5000/  
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
      Executing action method signalR_test.Controllers.HomeController.Index (signalR_test) with arguments ((null)) - ModelState is Valid
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executing action method signalR_test.Controllers.HomeController.Index (signalR_test) with arguments ((null)) - ModelState is Valid
info: Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor[1]
 Executing ViewResult, running view at path /Views/Home/Index.cshtml.
Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor:Information: Executing ViewResult, running view at path /Views/Home/Index.cshtml.
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
      Executed action signalR_test.Controllers.HomeController.Index (signalR_test) in 11.293ms
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executed action signalR_test.Controllers.HomeController.Index (signalR_test) in 11.293ms
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
      Request finished in 17.8879ms 200 text/html; charset=utf-8
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request finished in 17.8879ms 200 text/html;

it also said that it cannot open or find these files :
System.Binary.dll
System.Text.Formatting.dll
System.Text.Primitives.dll
System.IO.Pipelines.Text.Primitives.dll

and this is the outpu of dotnet restore command

C:\Users\...\Desktop\SignalR-dev\SignalR-dev\samples\ChatSample>dotnet resto
re
log  : Restoring packages for C:\Users\...\Desktop\SignalR-dev\SignalR-dev\s
amples\ChatSample\project.json...
log  : Restoring packages for tool 'BundlerMinifier.Core' in C:\Users\...\De
sktop\SignalR-dev\SignalR-dev\samples\ChatSample\project.json...
log  : Restoring packages for tool 'Microsoft.AspNetCore.Razor.Tools' in C:\User
s\...\Desktop\SignalR-dev\SignalR-dev\samples\ChatSample\project.json...
log  : Restoring packages for tool 'Microsoft.AspNetCore.Server.IISIntegration.T
ools' in C:\Users\...\Desktop\SignalR-dev\SignalR-dev\samples\ChatSample\pro
ject.json...
log  : Failed to download package from 'https://api.nuget.org/v3-flatcontainer/s
ystem.diagnostics.process/4.3.0-preview1-24530-04/system.diagnostics.process.4.3
.0-preview1-24530-04.nupkg'.
log  : An error occurred while sending the request.
log  :   The server returned an invalid or unrecognized response
log  : Failed to download package from 'https://api.nuget.org/v3-flatcontainer/s
ystem.diagnostics.process/4.3.0-preview1-24530-04/system.diagnostics.process.4.3
.0-preview1-24530-04.nupkg'.
log  : An error occurred while sending the request.
log  :   The server returned an invalid or unrecognized response
log  : Retrying 'FindPackagesByIdAsyncCore' for source 'https://www.postsharp.ne
t/nuget/packages/FindPackagesById()?id='System.Reflection.Emit.ILGeneration''.
log  : An error occurred while sending the request.
log  :   The server returned an invalid or unrecognized response
log  : Retrying 'FindPackagesByIdAsync' for source 'https://dotnetmyget.blob.cor
e.windows.net/artifacts/aspnetcore-ci-dev/nuget/v3/flatcontainer/system.security
.claims/index.json'.
log  : An error occurred while sending the request.
log  :   The server returned an invalid or unrecognized response
log  : Retrying 'FindPackagesByIdAsyncCore' for source 'https://www.postsharp.ne
t/nuget/packages/FindPackagesById()?id='System.Security.Claims''.
log  : An error occurred while sending the request.
log  :   The server returned an invalid or unrecognized response
log  : Retrying 'FindPackagesByIdAsyncCore' for source 'https://www.postsharp.ne
t/nuget/packages/FindPackagesById()?id='System.Security.Principal''.
log  : An error occurred while sending the request.
log  :   The server returned an invalid or unrecognized response
log  : Retrying 'FindPackagesByIdAsync' for source 'https://dotnetmyget.blob.cor
e.windows.net/artifacts/aspnetcore-ci-dev/nuget/v3/flatcontainer/system.security
.principal/index.json'.
log  : An error occurred while sending the request.
log  :   The server returned an invalid or unrecognized response
log  : Retrying 'FindPackagesByIdAsync' for source 'https://dotnetmyget.blob.cor
e.windows.net/artifacts/aspnetcore-ci-dev/nuget/v3/flatcontainer/system.security
.claims/index.json'.
log  : An error occurred while sending the request.
log  :   The server returned an invalid or unrecognized response
log  : Retrying 'FindPackagesByIdAsync' for source 'https://dotnetmyget.blob.cor
e.windows.net/artifacts/aspnetcore-ci-dev/nuget/v3/flatcontainer/system.security
.principal/index.json'.
log  : An error occurred while sending the request.
log  :   The server returned an invalid or unrecognized response
error: Failed to retrieve information from remote source 'https://dotnetmyget.bl
ob.core.windows.net/artifacts/aspnetcore-ci-dev/nuget/v3/flatcontainer/system.se
curity.claims/index.json'.
error: An error occurred while sending the request.
error:   The server returned an invalid or unrecognized response
error: Failed to retrieve information from remote source 'https://dotnetmyget.bl
ob.core.windows.net/artifacts/aspnetcore-ci-dev/nuget/v3/flatcontainer/system.se
curity.claims/index.json'.
error:   An error occurred while sending the request.
error:   The server returned an invalid or unrecognized response
error: Failed to retrieve information from remote source 'https://dotnetmyget.bl
ob.core.windows.net/artifacts/aspnetcore-ci-dev/nuget/v3/flatcontainer/system.se
curity.principal/index.json'.
error: An error occurred while sending the request.
error:   The server returned an invalid or unrecognized response

The Hub protocol needs framing

Right now we're getting lucky that JSON.Parse works client side. In fact, it can break easily if you send enough data. This happens with long polling more often than not because it falls behind when data is sent between polls.

Catch exceptions from formatters

Since formatters are pluggable they can fail in unexpected ways bringing the server down e.g:

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.AspNetCore.SignalR.JsonNetInvocationAdapter.<>c__DisplayClass2_0.<ReadInvocationDescriptorAsync>b__0() i
n C:\source\SignalR-Core\src\Microsoft.AspNetCore.SignalR\JsonNetInvocationAdapter.cs:line 40
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Microsoft.AspNetCore.SignalR.HubEndPoint`2.<DispatchMessagesAsync>d__9.MoveNext() in C:\source\SignalR-Core\src\Mi
crosoft.AspNetCore.SignalR\HubEndPoint.cs:line 105
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at Microsoft.AspNetCore.SignalR.HubEndPoint`2.<OnConnectedAsync>d__8.MoveNext() in C:\source\SignalR-Core\src\Microso
ft.AspNetCore.SignalR\HubEndPoint.cs:line 77
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.SignalR.HubEndPoint`2.<OnConnectedAsync>d__8.MoveNext() in C:\source\SignalR-Core\src\Microso
ft.AspNetCore.SignalR\HubEndPoint.cs:line 95
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at Microsoft.AspNetCore.Sockets.HttpConnectionDispatcher.<>c__DisplayClass4_0`1.<<ExecuteAsync>b__0>d.MoveNext() in C
:\source\SignalR-Core\src\Microsoft.AspNetCore.Sockets\HttpConnectionDispatcher.cs:line 116
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.QueueUserWorkItemCallbackDefaultContext.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()

We need to catch exceptions and handle them.

.NET Client To Do List

  • Add functional tests
  • Add generic overloads for the On method of the HubConnection - #311
  • Rename RpcConnection file to match HubConnection
  • Make sure we aren't getting the split messages issue as seen in #6
  • Clean up the public api - #311
  • Support WebSockets transport
  • Support SSE transport #309
  • handle cases where a method called from the server does not exist on the client - #312
  • client needs invoke overload for void methods - #311
  • re-usability of transports - currently the (longpolling transport) can be reused after it has been Disposed() #310
  • figure out ownership of transport - currently transports are passed to StartAsync and then Disposed in the Connection.Dispose() (maybe there should be a Stop() method?) -#310
  • re-entrancy - StartAsync on a transport should throw if the transport is already running
  • do we need to enable to close both Input/Output channels forcibly (example - right now if the user calls connection.Output.TryComplete(), connection.Input.Completion task will not be completed until the channel is drained) ?
  • do we need Send method and Receive callback on Connection instead of exposing Input/Output - writing data/receiving data is really gross now with having to create messages and PreservedBuffer) - or make it easier to create/read from Message
  • do we need to track the state of the client? It is impossible to tell what state the client is in if the client is disconnected but the channel is not drained (this in turn makes it impossible to create the Closed event hanging on the Completion task)
  • do not expose channels (#141)
  • remove ContinueWith() (#141)
  • consider removing the Running task from Transport - it's not part of interface and is a bit weird #141 - not doing at the moment - it is useful for testing.

Timed out poll connections kill the connection

If a poll connection times out the server throws:

System.InvalidOperationException occurred
  HResult=-2146233079
  Message=Concurrent reads are not supported.
  Source=System.Private.CoreLib
  StackTrace:
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Channels.Channel.Channels.IReadableBufferAwaiter.GetResult()
       at Microsoft.AspNetCore.Sockets.LongPolling.<ProcessRequestAsync>d__3.MoveNext() in C:\source\NetworkingProtoype\src\Microsoft.AspNetCore.Sockets\LongPolling.cs:line 21
  InnerException: 

and kills the connection. The client restarts the poll only to get:

GET http://localhost:5000/hubs/poll?id=87085e15-6bb5-492e-850b-f7965c7e9bbc&87085e15-6bb5-492e-850b-f7965c7e9bbc 500 (Internal Server Error)

Is it possible to use generic Hub<IClientProxy>?

Is it possible to use a generic SignalR hub from Microsoft.AspNetCore.SignalR?

public class DriverHub : Hub<IDriverClient>

I cannot instantiate it
I have to map it this way

            //app.UseSignalR(routes =>
            //{
            //    routes.MapHub<PassengersHub>("/Passenger");
            //    routes.MapHub<DriversHub>("/Driver");
            //});
            app.UseSockets(routes =>
            {
                routes.MapEndpoint<HubEndPoint<PassengerHub, IPassengerClient>>(Routes.PassengerArea1);
                routes.MapEndpoint<HubEndPoint<DriverHub, IDriverClient>>(Routes.DriverArea1);
            });

But adding

            services.AddSignalR();
            // Missing in AddSignalR
            services.AddSingleton(typeof(HubEndPoint<,>), typeof(HubEndPoint<,>));
            services.AddSingleton(typeof(IHubContext<,>), typeof(HubContext<>));

Does not help, because of generic arguments count mismatch

Standalone client and server

I was thinking of using this across two separate applications, where the server is an API without any frontend whatsoever, and the frontend is a pure javascript app served via nodejs. Is this usage recommended, or even supported?

I suppose I can use nuget to get the package in my backend application, and use something like npm install --save https://github.com/aspnet/SignalR to get a hold of it in my frontend and then compile it myself using webpack, but then I will have unneeded .cs files in my node_modules, and unneeded .ts-files in my server (I will probably also need the typescript compiler in my server without any frontend). It feels like I am doing something wrong or misunderstanding something. Is there an easier way to split up the client and server code, or is this use case maybe not supported at this time?

AutobahnTest fails to run

System.OperationCanceledException : Failed to connect, retry canceled.
   at Microsoft.AspNetCore.Server.IntegrationTesting.RetryHelper.<RetryRequest>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.WebSockets.Internal.ConformanceTest.Autobahn.AutobahnTester.<DeployTestAndAddToSpec>d__12.MoveNext() in \test\Microsoft.AspNetCore.WebSockets.Internal.ConformanceTest\Autobahn\AutobahnTester.cs:line 127
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.WebSockets.Internal.ConformanceTest.AutobahnTests.<AutobahnTestSuite>d__0.MoveNext() in \test\Microsoft.AspNetCore.WebSockets.Internal.ConformanceTest\AutobahnTests.cs:line 50
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
======= Failed test run #2 ==========
System.OperationCanceledException : Failed to connect, retry canceled.
   at Microsoft.AspNetCore.Server.IntegrationTesting.RetryHelper.<RetryRequest>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.WebSockets.Internal.ConformanceTest.Autobahn.AutobahnTester.<DeployTestAndAddToSpec>d__12.MoveNext() in \test\Microsoft.AspNetCore.WebSockets.Internal.ConformanceTest\Autobahn\AutobahnTester.cs:line 127
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.WebSockets.Internal.ConformanceTest.AutobahnTests.<AutobahnTestSuite>d__0.MoveNext() in \test\Microsoft.AspNetCore.WebSockets.Internal.ConformanceTest\AutobahnTests.cs:line 50
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

Don't allow WebSocketsTransport to be half-closed

(via @anurse in person)

The WebSockets transport currently allows a half-close situation, where one party has closed but the other can still send. That's technically valid per the spec, but I don't think it's a valuable scenario and it causes confusion.

Design meeting notes 10/25/2016

  • Move Sockets to SignalR repo
  • Scaleout Redis/Sql prototype working
  • Scaleout requires sticky sessions (supported by default by Antares)
  • Do we support keep-alives?
    • websockets have keep alive built in
    • long polling should not support-keep alive
    • ServenSentEvents? Connections can be terminated due to a timeout - sent keep alive to prevent this or use automatic reconnection feature? Keep alives can be implemented at the transport level not connection/signalr level
  • Server Sent Events automatic reconnection should be handled somehow - should we fail the connection or allow to silently reconnect? Other transports won't try to reconnect silently they will just fail the connection
  • Negotiation should send urls to send/receive enpoints
  • Consider sending connection id in a response header in long polling so negotiation is not needed
  • Possibly send connection id over SSE to not require negotiation
  • When using websockets the client won't be able to get the connection id when started without negotiation but it is not needed
  • 'Connection id' should be just urls - send/receive e.g. negotiate response could look like:
{
  "transports": {
    "ws": {
      url: "/chat/ws"
    },
    "longpolling": {
      receive: "/banana",
      send:"/?id=1231"
    },
    "sse": {
      receive:"/blah",
      send:"/?id=3213"
    }
  }
} 

  • Consider allowing a formatter to format negotiation response. These formatters most likely will be different from custom formatters for data sent over the channel since negotiate is always HTTP and data can be binary
  • Consider separating callbacks from connection. What happens if a connection is lost and restarted and messages are missing - some callbacks would never be called/invocation would never end)
  • TODO: Investigate how signals are supposed to work?
  • TODO: Try writing a chat client with rooms/group and presence, private messages, message history/persistence (#1)

WebServer taken down due to an exception from channels

Not sure where the bug is. It is related to #4. I think there was a write when the connection was being killed due to XmlHttpRequest time out. It brought the entire server down.

System.InvalidOperationException occurred
HResult=-2146233079
Message=No ongoing producing operation. Make sure Alloc() was called.
Source=Channels
StackTrace:
at Channels.Channel.AdvanceWriter(Int32 bytesWritten)
at Channels.DefaultWritableBufferExtensions.Write(WritableBuffer buffer, Span1 source) at Channels.WritableChannelExtensions.WriteAsync(IWritableChannel channel, Span1 source)
at Channels.ChannelStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at Microsoft.AspNetCore.SignalR.JsonNetInvocationAdapter.Write(Object value, Stream stream) in C:\source\NetworkingProtoype\src\Microsoft.AspNetCore.SignalR\JsonNetInvocationAdapter.cs:line 39
at Microsoft.AspNetCore.SignalR.JsonNetInvocationAdapter.WriteInvocationDescriptorAsync(InvocationDescriptor invocationDescriptor, Stream stream) in C:\source\NetworkingProtoype\src\Microsoft.AspNetCore.SignalR\JsonNetInvocationAdapter.cs:line 31
at Microsoft.AspNetCore.SignalR.DefaultHubLifetimeManager1.InvokeAllWhere(String methodName, Object[] args, Func2 include) in C:\source\NetworkingProtoype\src\Microsoft.AspNetCore.SignalR\DefaultHubLifetimeManager.cs:line 68
at Microsoft.AspNetCore.SignalR.DefaultHubLifetimeManager1.InvokeAllAsync(String methodName, Object[] args) in C:\source\NetworkingProtoype\src\Microsoft.AspNetCore.SignalR\DefaultHubLifetimeManager.cs:line 46 at Microsoft.AspNetCore.SignalR.AllClientProxy1.InvokeAsync(String method, Object[] args) in C:\source\NetworkingProtoype\src\Microsoft.AspNetCore.SignalR\Proxies.cs:line 53
at SocketsSample.Hubs.Chat.d__1.MoveNext() in C:\source\NetworkingProtoype\samples\SocketsSample\Hubs\Chat.cs:line 16
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
InnerException:

Select message formatter

I want be able to pass required format at connect request and then all the messages be formatted with it.
I. e. JSON, BSON, XML, etc.

Reconnects

If a request comes in with the same connection id for long polling (only), close the previous poll with a zero byte read. We have to await the previous transport task so make sure it unwinds properly.

For other transport, reject connections with a 409 for an existing connection id.

Consider renaming Microsoft.AspNetCore.SignalR.AuthorizeAttribute

When calling a hub from a MVC controller that Authorize decorated on the class or method/view for example, there is an ambiguous reference between Microsoft.AspNetCore.SignalR.AuthorizeAttribute and Microsoft.AspNetCore.Authorization.AuthorizeAttribute. If you rename Microsoft.AspNetCore.SignalR.AuthorizeAttribute to Microsoft.AspNetCore.SignalR.Authentication.AuthorizeAttribute, you would remove this ambiguity.

Improve WebSocket testing

Need functional tests (which needs #26) and unit tests (which need a little refactoring of the transport to take an existing socket rather than handshaking).

Also need handshaking tests.

Hubs can be stateful and bad things will happen

If a Hub is registered in the DI container as a Singleton it will be stateful. Each connection will get the same instance and we will try to set it up from multiple threads causing crashes and unexpected behavior.

Use message formatters defined by host

I set default enum serialization as string

            services.AddMvc()
                    .AddJsonOptions(opt =>
                    {
                        var settings = opt.SerializerSettings;
                        settings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
                    });

But old one SignalR did not use that.

Longer messages get split into chunks of 1024 characters

I was trying to call a function from server to a JS client with parameter string which is around 5000 characters long. The message, however, was split into chunks of 1024 bytes and sent multiple times (that is, firstly, chunk 0-1024 is sent, then 1024-2048, etc). This resulted in a corrupt JSON, as you can imagine, library is trying to read message by message, and it gets chunks instead. This happens on WebSocket transport and ServerSideEvents transport (long polling transport works).
Is there a way to change the max length of text that I can send, or will you upgrade the client that he knows how to receive these multipart messages.

Groups.Exists(groupName) and Public Access to ConnectionList

I started to implement these two options in my project and I saw that currently there is no way of doing it without some hacking.

My idea was to have a property in Connection.Metadata called "LastSeen" or "UserStatus", and generally, I could access ConnectionList then I could access their Metadata and get a list of all online users.

I think Groups.Exists is also mandatory to have to see if the group exists, especially if someone wants to use Single-user groups.

Did you plan to add these features, and when approximately? :)

How to debug "Server negotiation failed." ?

How can I find why this happens?

Request starting HTTP/1.1 GET http://localhost:1965/1/Driver/negotiate?clientProtocol=1.4&connectionData=[%7B%22Name%22:%22DriverHub%22%7D]

            app.UseSignalR(routes =>
            {
                routes.MapHub<PassengerHub>(Routes.PassengerArea1); // PassengerArea1 = "/1/Passenger";
                routes.MapHub<DriverHub>(Routes.DriverArea1); // DriverArea1 = "/1/Driver";
            });

Microsoft.AspNet.SignalR.Client

        static void Main(string[] args)
        {
            var connection = new HubConnection("http://localhost:1965/1/Driver", false);
            var proxy = connection.CreateHubProxy("DriverHub");
            connection.Start().Wait();
        }

Chat Sample account creation doesn't work

The chat sample has issues with the versions of the EF packages preventing you from creating new users.
@BrennanConroy

fail: Microsoft.EntityFrameworkCore.Query.Internal.SqlServerQueryCompilationContextFactory[1]
      An exception occurred in the database while iterating the results of a query.
      System.Data.SqlClient.SqlException: Cannot open database "aspnet-ChatSample-f11cf018-e0a8-49fa-b749-4c0eb5c9150b" requested by the login. The login failed.
      Login failed for user 'REDMOND\mimengis'.
         at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling)
         at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
         at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
         at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
         at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
         at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
         at System.Data.ProviderBase.DbConnectionPool.WaitForPendingOpen()
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

Client transport exception handling

We need robust testing of exceptions in the client transports. There are a background tasks running and we need to make sure that exceptions properly shut down the background tasks and report the error to user code.

TS Compilation Errors in ServerSentEventsTransports.ts

There are multiple compilation errors project TypeScript Virtual Projects:

  • Cannot fine name EventSource
  • Type Promise<{}> is not assignable

These are referenced in via the sample apps (ChatSample, SocketsSample) and unloaded these projects allows you to build.

Add support for messaging transports

All our current transports actually produce Messages, which have known lengths.

  • WebSockets have frames
  • /send has Content-Length
  • Server-sent Events has framing
  • Long-Polling returns a single message in one poll (right now), and when we add batching it will return whole messages.

So, we should provide a representation that preserves that. We'll also provide a model for streaming endpoints which flatten those messages out, depending on what the app-developer wants.

sample compilation vs2017 rc1 client/etc. TS not compiled

using signalr 1 preview 1 in vs 2017 rc1 projects the ts compilation does not occur.
where is the location of the files for msbuild to reference?

  <Target Name="PrepublishScript" BeforeTargets="PrepareForPublish" Condition=" '$(IsCrossTargetingBuild)' != 'true' ">
    <Exec Command="bower install" />
    <Exec Command="dotnet bundle" />
    <Exec Command="npm run gulp -- --gulpfile %project:Directory%/../../src/Microsoft.AspNetCore.SignalR.Client.TS/gulpfile.js bundle-client --bundleOutDir %project:Directory%/wwwroot/lib/signalr-client/" />
  </Target>

Dependency Injection in Hubs

I wanted to access some repositories/services from within a hub, is that possible now? Will you implement this feature later?

Case issues

Let's say we have a model like this on the server side:

class Person
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
}

A Asp.Net Core Controller serializes this to a JSON with 'firstName' and 'lastName'. So all my client-side classes use this convention.

I realized that SignalR serializes this to 'FirstName' and 'LastName'. This means I can't re-use my client-side classes.

  • Is there an easy way to configure this behaviour in SignalR?
  • If not, what's the recommended workaround?
  • It would be nice if the default behaviour of SignalR was the same as for Controllers.

Sample work

  • Add chat rooms (groups)
  • Private Message (send to individual)
  • Presence
  • History/Persistence

TS-client outstanding work

As per davidfowl/Sockets#12

  • add transport closed event (33c94c1)
  • remove fallback as per discussion today (325c909)
  • figure out modules (2039a18)
  • unify errors (33c94c1, 913354f)
  • review capturing of this in callbacks/eventhandlers (b32d3ad)
  • logging tracked now as: #485
  • convert RpcConnection to HubConnection (e6b34fd)
  • detach dispatching from transports/connection (70e4ec9)
  • enable plugging in custom formatters (#12)
  • split messages (#6)
  • joined messages (especially important for longpolling - multiple messages in one poll response) (78dfd27)
  • is there a better way of bringing typings for EventSource (currently we have them in the repo: 02c9813)
  • tests
  • consider using async/await (requires typescript 2.1.1?) (3a01d6c)
  • handle cases where a method called from the server does not exist on the client
  • hubConnection needs error event (2bbca5e)
  • review usages of httpClient. It shouldn't be created each time it is needed and it should be possible to provide alternate implementations (e.g. for mocking) (a9c7e14)
  • try using IHttpClient for polling
  • don't build the client multiple times when running build.cmd (after moving to MSBuild) (0162c19)
  • create typescript VS projects so that they show up in VS (0162c19)
  • ccabbbc#commitcomment-20536735

Make .NET client

We need to look at the ability to run the formatter code directly on the client.

"No Channel" exception in long polling

When running end to end tests I am working on I semi occasionally (25% of times) receive this:

info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/testhub/getid?formatType=json&format=text
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
      Request finished in 0.2851ms 200
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 POST http://localhost:5000/testhub/send?id=055127ed-e4f0-421d-96f7-eaf32a251ced&055127ed-e4f0-421d-96f7-eaf32a251ced application/x-www-form-urlencoded 120
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/testhub/poll?id=055127ed-e4f0-421d-96f7-eaf32a251ced&055127ed-e4f0-421d-96f7-eaf32a251ced
fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HL0PDKEHGN48": An unhandled exception was thrown by the application.
System.InvalidOperationException: No channel
   at Microsoft.AspNetCore.Sockets.HttpConnectionDispatcher.ProcessSend(HttpContext context) in C:\source\SignalR-Core\src\Microsoft.AspNetCore.Sockets\HttpConnectionDispatcher.cs:line 214
   at Microsoft.AspNetCore.Sockets.HttpConnectionDispatcher.<ExecuteAsync>d__4`1.MoveNext() in C:\source\SignalR-Core\src\Microsoft.AspNetCore.Sockets\HttpConnectionDispatcher.cs:line 36
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware.<Invoke>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Frame`1.<RequestProcessingAsync>d__2.MoveNext()
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
      Request finished in 3.1934ms 500

Notice that send was send before the first poll

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.