Azure SignalR Service è il servizio che su Azure ci permette di scalare Signaler, ovvero il nostro framework per l'utilizzo del WebSocket. Il servizio è disponibile anche per applicazioni serverless, seppur con le dovute limitazioni
1. 1
La Storia di SignalR
Dalla nascita alla ri-nascita
AzureConference
1
2. 2
I creatori
David Fowler Damian Edwards
SignalR nacque nel 2011
Socket.io, release (0.1.0), il 19/03/2010
3. 3
La storia in ASP .NET
Fu portato nel progetto ASP.NET nel 2013.
In quell’anno WebSocket era un protocollo, appena
standardizzato, ma che molti browser non conoscevano.
Si utilizzavano tecnichiche come polling e altre tecniche
come il Server-Side Event non erano ancora
completamente implementate dai browser.
SignalR nacque per risolvere il problema e inserire un
supporto all’interno dello stack ASP .NET. SignalR divenne
una libreria di riferimento per il RealTime.
4. 4
La storia in ASP .NET
SignalR quindi si fa carico di negoziare il miglior
protocollo di trasporto disponibile per la comunicazione.
SignalR, alla nascita, era strettamente accoppiato a jQuery.
Il web di allora lo era quasi interamente.
Altre funzionalità native dello strumento:
• Riconnessione automatica
• Scalabilità chiavi in mano (Service-Bus)
6. 6
La rinascita
Nel 2018 viene interamente riscritto.
Nessuna dipendenza con la libreria jQuery.
Scalabilità (Redis – Azure SignalR Service)
Cross-platform
Estendibile
Disponibile dalla versione ASP .NET Core 2.1
Client: Javascript – Typescript – .NET - Node.js - Python
Prossime release: Java e C++
Planning: Go, PHP
7. 7
I pacchetti disponibili per ASP .NET Signlar
ASP .NET:
https://www.nuget.org/packages/Microsoft.AspNet.SignalR/
JavaScript:
https://www.nuget.org/packages/Microsoft.AspNet.SignalR.JS/
C++: https://github.com/SignalR/SignalR-Client-Cpp
NodeJS: None
PHP: None
Go: None
Python: https://pypi.org/project/signalr-client/
Java: https://github.com/SignalR/java-client
8. 8
I pacchetti disponibili per ASP .NET Core Signalr
ASP .NET Core: 'Microsoft.AspNetCore.SignalR.Client' on NuGet
(https://www.nuget.org/packages/Microsoft.AspNetCore.SignalR/)
Java: 'com.microsoft.aspnet:signalr' on Maven
(https://search.maven.org/artifact/com.microsoft.aspnet/signalr)
JavaScript (including NodeJS): '@aspnet/signalr' on NPM
(https://www.npmjs.com/package/@aspnet/signalr)
C++: (Prototype) https://github.com/aspnet/SignalR/tree/master/clients/cpp
(no official release planned yet)
Swift: (Unofficial) SwiftSignalRClient on CocoaPods
(https://github.com/moozzyk/SignalR-Client-Swift)
PHP ?
Go: Planning
Python: Planning
https://github.com/aspnet/SignalR/tree/release/2.2/specs Per contribuire
10. “A transport is required to have
the following attributes:
Duplex
Binary-safe
Text-safe
11. 14
SignalR
The only transport which fully implements the duplex
requirement is WebSockets
The others are "half-transports" which implement one end of
the duplex connection.
They are used in combination to achieve a duplex connection.
12. 15
SignalR
ASP.NET Core SignalR was built to be a general purpose
RPC(remote procedure call) based communication library.
It supports:
• Multicast
• Broadcast
• Groups
• Bidirectional RPC
• Streaming
28. 31
Streaming
ASP.NET Core SignalR supporta streaming valori restituiti
dei metodi del server.
Ciò è utile per scenari in cui verranno inviati frammenti di
dati nel corso del tempo.
Quando un valore restituito viene trasmesso al client, non
appena diventa disponibile, anziché attendere che tutti i dati
diventino disponibili.
29. 32
Streaming – oggetti da utilizzare
ChannelReader<T>
Restituisce un valore non appena disponibile.
ChannelWriter<T>
Consente la scrittura di dati all’interno di uno stream.
41. 44
Azure SignalR Services
SignalR è un servizio completamente gestito.
puoi implementarlo in un ambiente multiserver senza
preoccuparti di:
• hosting,
• scalabilità,
• bilanciamento del carico
• autenticazione.
42. 45
Azure SignalR Services
More regions. SignalR Service is now available in the
following regions: US East, US East 2, US Central, US West, US
West 2, Canada East, West Europe, North Europe, Southeast
Asia, Australia East, and Japan East. And in the coming
months we will add more regions.
More reliability. The Azure SignalR Service GA offers 99.9%
availability with a service level agreement for production use.
More capacity. During its preview, the SignalR Service was
limited to 10K connections in the Standard Tier. With GA, it
increases to 100K connections per instance. Through
sharding or partitioning, users can configure multiple
instances to handle an even larger scale.
50. 53
Grazie a una estensione per Azure Functions non è
necessario avere la parte server di SignalR su una
applicazione ASP .NET Core.
L’estensione ha grossi limiti, ma per alcuni sceri può essere
utile.
https://github.com/anthonychu/AzureAdvocates.WebJobs.Extensions.SignalRService OLD
Current limitations
•Only supports broadcasting at this time, cannot invoke methods on a subset of connections,
users, or groups
•Functions cannot be triggered by client invocation of server methods (clients need to call an
HTTP endpoint or post messages to a Event Grid, etc, to trigger a function)
https://github.com/Azure/azure-functions-signalrservice-extension NEW
https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.SignalRService
Azure SignalR Services – Serverless
51. 54
Supported scenarios
•Allow clients to serverlessly connect to a SignalR Service hub
without requiring an ASP.NET Core backend
•Use Azure Functions (any language supported by V2) to broadcast
messages to all clients connected to a SignalR Service hub
Bindings
SignalRConnectionInfo input binding makes it easy to generate the
token required for clients to initiate a connection to Azure SignalR
Service.
SignalR output binding allows messages to be broadcast to an Azure
SignalR Service hub.
Azure SignalR Services – Serverless
57. 60
Azure SignalR Service - il WebSocket che tanto ci mancava
ATosato86
andreatosato
andrea.tosato
CloudGen Verona
aspitalia.com
4ward
ANDREA TOSATO
Editor's Notes
Forever Frame creates a hidden IFrame which makes a request to an endpoint on the server that does not complete. The server then continually sends script to the client which is immediately executed, providing a one-way realtime connection from server to client. The connection from client to server uses a separate connection from the server to client connection, and like a standard HTTP request, a new connection is created for each piece of data that needs to be sent.
Crea JWT Token: http://jwtbuilder.jamiekurtz.com/
Port
REST APIs are only exposed on port 5002.
Authentication
In each HTTP request, an authorization header with a JSON Web Token (JWT) is required to authenticate with Azure SignalR Service.
Signing Algorithm and Signature
HS256, namely HMAC-SHA256, is used as the signing algorithm.
You should use the AccessKey in Azure SignalR Service instance's connection string to sign the generated JWT token.
Claims
aud (audience) and exp(expiration time) are required claims in the JWT token.
The aud claim should be exactly the same as your HTTP request url, trailing slash and query paramters not included. For example, a broadcast request's audience should look like as below:
https://example.service.signalr.net:5002/api/v1-preview/hub/myhub
Esempio:
https://github.com/aspnet/AzureSignalR-samples/tree/master/samples/Serverless
Crea JWT Token: http://jwtbuilder.jamiekurtz.com/
Port
REST APIs are only exposed on port 5002.
Authentication
In each HTTP request, an authorization header with a JSON Web Token (JWT) is required to authenticate with Azure SignalR Service.
Signing Algorithm and Signature
HS256, namely HMAC-SHA256, is used as the signing algorithm.
You should use the AccessKey in Azure SignalR Service instance's connection string to sign the generated JWT token.
Claims
aud (audience) and exp(expiration time) are required claims in the JWT token.
The aud claim should be exactly the same as your HTTP request url, trailing slash and query paramters not included. For example, a broadcast request's audience should look like as below:
https://example.service.signalr.net:5002/api/v1-preview/hub/myhub
Esempio:
https://github.com/aspnet/AzureSignalR-samples/tree/master/samples/Serverless
Portale
Scalabilita (Up – Out)
ASP .NET Core Secret
Startup progetto
Portale
Scalabilita (Up – Out)
ASP .NET Core Secret
Startup progetto