You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-signalr/signalr-concept-internals.md
+44-29Lines changed: 44 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,51 +6,58 @@ ms.service: signalr
6
6
ms.topic: conceptual
7
7
ms.devlang: csharp
8
8
ms.custom: devx-track-csharp
9
-
ms.date: 11/13/2019
9
+
ms.date: 01/05/2023
10
10
ms.author: lianwei
11
11
---
12
12
# Azure SignalR Service internals
13
13
14
14
Azure SignalR Service is built on top of ASP.NET Core SignalR framework. It also supports ASP.NET SignalR by reimplementing ASP.NET SignalR's data protocol on top of the ASP.NET Core framework.
15
15
16
-
You can easily migrate a local ASP.NET Core SignalR application or ASP.NET SignalR application to work with SignalR Service, with a few lines of code change.
16
+
You can easily migrate a local ASP.NET Core SignalR or an ASP.NET SignalR application to work with SignalR Service, with a few lines of code change.
17
17
18
-
The diagram below describes the typical architecture when you use the SignalR Service with your application server.
18
+
The diagram describes the typical architecture when you use the SignalR Service with your application server.
19
19
20
20
The differences from self-hosted ASP.NET Core SignalR application are discussed as well.
A self-hosted ASP.NET Core SignalR application server listens to and connects clients directly.
25
26
26
-
Self-hosted ASP.NET Core SignalR application server listens to and connects clients directly.
27
-
28
-
With SignalR Service, the application server is no longer accepting persistent client connections, instead:
27
+
With SignalR Service, the application server no longer accepts persistent client connections, instead:
29
28
30
29
1. A `negotiate` endpoint is exposed by Azure SignalR Service SDK for each hub.
31
-
1.This endpoint will respond to client's negotiation requests and redirect clients to SignalR Service.
32
-
1.Eventually, clients will be connected to SignalR Service.
30
+
1.The endpoint will respond to client's negotiation requests and redirect clients to SignalR Service.
31
+
1.The clients connect to SignalR Service.
33
32
34
33
For more information, see [Client connections](#client-connections).
35
34
36
-
Once the application server is started,
37
-
- For ASP.NET Core SignalR, Azure SignalR Service SDK opens 5 WebSocket connections per hub to SignalR Service.
38
-
- For ASP.NET SignalR, Azure SignalR Service SDK opens 5 WebSocket connections per hub to SignalR Service, and one per application WebSocket connection.
35
+
Once the application server is started:
36
+
37
+
- For ASP.NET Core SignalR: Azure SignalR Service SDK opens five WebSocket connections per hub to SignalR Service.
38
+
- For ASP.NET SignalR: Azure SignalR Service SDK opens five WebSocket connections per hub to SignalR Service, and one per application WebSocket connection.
39
+
40
+
41
+
The initial number of connections defaults to 5 and is configurable using the `InitialHubServerConnectionCount` option in the SignalR Service SDK. For more information, see [configuration](https://github.com/Azure/azure-signalr/blob/dev/docs/run-asp-net-core.md#maxhubserverconnectioncount).
42
+
43
+
While the application server is connected to the SignalR service, the Azure SignalR service may send load-balancing messages to the server. Then, the SDK starts new server connections to the service for better performance.
39
44
40
-
5 WebSocket connections is the default value that can be changed in [configuration](https://github.com/Azure/azure-signalr/blob/dev/docs/run-asp-net-core.md#connectioncount). Please note that this configures the initial server connection count the SDK starts. While the app server is connected to the SignalR service, the Azure SignalR service might send load-balancing messages to the server and the SDK will start new server connections to the service for better performance.
45
+
<!-- Question: What does this mean? Are the connections client <-> service? -->
46
+
Messages to and from clients are multiplexed into these connections.
41
47
42
-
Messages to and from clients will be multiplexed into these connections.
43
48
44
-
These connections will remain connected to the SignalR Service all the time. If a server connection is disconnected for network issue,
45
-
- all clients that are served by this server connection disconnect (for more information about it, see [Data transmit between client and server](#data-transmit-between-client-and-server));
46
-
- the server connection starts reconnecting automatically.
49
+
Server connections are persistently connected to the SignalR Service. If a server connection is disconnected due to a network issue:
50
+
51
+
- All clients served by this server connection disconnect (for more information, see [Data transmission between client and server](#data-transmission-between-client-and-server)).
52
+
- The server automatically reconnects the clients.
47
53
48
54
## Client connections
49
55
50
-
When you use the SignalR Service, clients connect to SignalR Service instead of application server.
51
-
There are two steps to establish persistent connections between the client and the SignalR Service.
56
+
When you use the SignalR Service, clients connect to the service instead of the application server.
57
+
There are three steps to establish persistent connections between the client and the SignalR Service.
52
58
53
-
1. Client sends a negotiate request to the application server. With Azure SignalR Service SDK, application server returns a redirect response with SignalR Service's URL and access token.
59
+
1. A client sends a negotiate request to the application server.
60
+
1. The application server uses Azure SignalR Service SDK to return a redirect response containing the SignalR Service URL and access token.
54
61
55
62
- For ASP.NET Core SignalR, a typical redirect response looks like:
56
63
```
@@ -68,21 +75,29 @@ There are two steps to establish persistent connections between the client and t
68
75
}
69
76
```
70
77
71
-
1. After receiving the redirect response, client uses the new URL and access token to start the normal process to connect to SignalR Service.
78
+
1. After the client receives the redirect response, it uses the URL and access token to connect to SignalR Service.
79
+
80
+
To learn more about ASP.NET Core SignalR's, see [Transport Protocols](https://github.com/aspnet/SignalR/blob/release/2.2/specs/TransportProtocols.md).
72
81
73
-
Learn more about ASP.NET Core SignalR's [transport protocols](https://github.com/aspnet/SignalR/blob/release/2.2/specs/TransportProtocols.md).
82
+
## Data transmission between client and server
74
83
75
-
## Data transmit between client and server
84
+
When a client is connected to the SignalR Service, the service runtime will find a server connection to serve this client.
76
85
77
-
When a client is connected to the SignalR Service, service runtime will find a server connection to serve this client
78
-
- This step happens only once, and is a one-to-one mapping between the client and server connections.
86
+
- This step happens only once, and is a one-to-one mapping between the client and server connection.
79
87
- The mapping is maintained in SignalR Service until the client or server disconnects.
80
88
81
89
At this point, the application server receives an event with information from the new client. A logical connection to the client is created in the application server. The data channel is established from client to application server, via SignalR Service.
82
90
83
-
SignalR Service transmits data from the client to the pairing application server. And data from the application server will be sent to the mapped clients.
91
+
SignalR Service transmits data from the client to the pairing application server. Data from the application server will be sent to the mapped clients.
92
+
93
+
SignalR Service doesn't save or store customer data, all customer data received is transmitted to target server or clients in real-time.
94
+
95
+
The Azure SignalR Service acts as a logical transport layer between application server and clients. All persistent connections are offloaded to SignalR Service. As a result, the application server only needs to handle the business logic in the hub class, without worrying about client connections.
96
+
97
+
## Next steps
84
98
85
-
SignalR Service does not save or store customer data, all customer data received is transmitted to target server or clients in real-time.
99
+
To learn more about Azure SignalR SDKs, see:
86
100
87
-
As you can see, the Azure SignalR Service is essentially a logical transport layer between application server and clients. All persistent connections are offloaded to SignalR Service.
88
-
Application server only needs to handle the business logic in hub class, without worrying about client connections.
0 commit comments