Upgrade to Pro — share decks privately, control downloads, hide ads and more …

SignalR Deep Dive

David Fowler
January 29, 2020

SignalR Deep Dive

You’ve likely already seen that SignalR supports multiple client types, including .NET, JavaScript, and Java. But what about the server side? Could we build a SignalR server in something other than .NET? Go perhaps, or Node.js? If so, what would you learn? Why would you do it? How would you even begin?

In this session, David and Damian from the ASP.NET team will explore what goes into building a SignalR server that can speak to any SignalR client. You’ll come away with a better understanding of exactly how SignalR works, and perhaps even ideas on how to extend SignalR further for your needs.

David Fowler

January 29, 2020

More Decks by David Fowler

Other Decks in Programming


  1. SignalR Deep Dive: Building Servers David Fowler – ASP.NET &

    Azure SignalR Architect @davidfowl Damian Edwards – ASP.NET Program Manager @damianedwards
  2. What is SignalR? • Framework for duplex RPC & streaming

    between client and server • Provides “real-time” messaging & server-push functionality • Protocols for transport and messaging layers allow broad reach • Server support for client addressing & grouping, e.g.: • Send to all clients • Send to this one client (connection or user) • Send to this group of clients
  3. Supporting multiple clients • SignalR supports different client types •

    HTTP transports • WebSockets • ServerSentEvents • Long Polling • Client SDKs • JavaScript • .NET • Java • Swift • Python • C++ (coming soon)
  4. How though? • This client flexibility is enabled by two

    protocol layers • Transport protocol provides flexibility for connection types, e.g. HTTP vs. TCP/IP • https://github.com/dotnet/aspnetcore/blob/master/src/SignalR/docs/specs/ TransportProtocols.md • Hub protocol provides flexibility for message formats, e.g. JSON vs. MessagePack • https://github.com/dotnet/aspnetcore/blob/master/src/SignalR/docs/specs/ HubProtocol.md
  5. Hub protocol message types Message Name Sender HandshakeRequest Client HandshakeResponse

    Server Close Callee, Caller Invocation Caller StreamInvocation Caller StreamItem Callee, Caller Completion Callee, Caller CancelInvocation Caller Ping Caller, Callee
  6. Further considerations • Thread safety • Error handling • Groups

    • Client-to-server streaming • Cancellation • Frame inter-leaving
  7. Messaging Transport frames message message message message Hub frames message

    message message message message message header payload WebSocket transport frame { "type": 6 } JSON ping { "type": 1, "target": "Send", "arguments": [ 42, "Test Message" ] } JSON non-blocking invocation
  8. Azure SignalR Service • Provides SignalR scale-out as a service

    • Offloads SignalR connection handling to the service • Relays client traffic to/from your app over few WebSockets • https://github.com/Azure/azure- signalr/blob/dev/specs/ServiceProtocol.md