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-client-negotiation.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ The first request between a client and a server is the negotiation request. When
16
16
17
17
The response to the `POST [endpoint-base]/negotiate` request contains one of three types of responses:
18
18
19
-
* A response that contains `connectionId`, which identifies the connection on the server and the list of the transports that the server supports:
19
+
* A response that contains `connectionId`, which identifies the connection on the server and the list of transports that the server supports:
20
20
21
21
```json
22
22
{
@@ -41,7 +41,7 @@ The response to the `POST [endpoint-base]/negotiate` request contains one of thr
41
41
42
42
The payload that this endpoint returns provides the following data:
43
43
44
-
* The `connectionId` value that the Long Polling and Server-Sent Events transports require to correlate sending and receiving.
44
+
* The `connectionId` value is required by the `LongPolling`and `ServerSentEvents`transports to correlate sending and receiving.
45
45
* The `negotiateVersion` value is the negotiation protocol version that you use between the server and the client.
46
46
* The `availableTransports` list describes the transports that the server supports. For each transport, the payload lists the name of the transport (`transport`) and a list of transfer formats that the transport supports (`transferFormats`).
47
47
@@ -72,7 +72,7 @@ The response to the `POST [endpoint-base]/negotiate` request contains one of thr
72
72
73
73
The payload that this endpoint returns provides the following data:
74
74
75
-
* The `error` string that gives details about why the negotiation failed.
75
+
* The `error` string gives details about why the negotiation failed.
76
76
77
77
When you use Azure SignalR Service, clients connect to the service instead of the app server. There are three steps to establish persistent connections between the client and Azure SignalR Service:
78
78
@@ -92,7 +92,7 @@ When you use Azure SignalR Service, clients connect to the service instead of th
92
92
1. After the client receives the redirect response, it uses the URL and access token to connect to SignalR Service. The service then routes the client to the app server.
93
93
94
94
> [!IMPORTANT]
95
-
> In self-hosted SignalR, some users might choose to skip client negotiation when clients support only WebSocket and save the round trip for negotiation. However, when you're working with Azure SignalR Service, clients should always ask a trusted server or a trusted authntication center to build the access token. So _don't_ set `SkipNegotiation` to `true` on the client side. `SkipNegotiation` means clients need to build the access token themselves. This setting brings a security risk that the client could do anything to the service endpoint.
95
+
> In self-hosted SignalR, some users might choose to skip client negotiation when clients support only WebSocket and save the round trip for negotiation. However, when you're working with Azure SignalR Service, clients should always ask a trusted server or a trusted authentication center to build the access token. So _don't_ set `SkipNegotiation` to `true` on the client side. `SkipNegotiation` means clients need to build the access token themselves. This setting brings a security risk that the client could do anything to the service endpoint.
When you have multiple app servers, there's no guarantee (by default) that the server that does negotiation and the server that gets the hub invocation are the same. In some cases, you might want to have client state information maintained locally on the app server.
123
123
124
-
For example, when you're using server-side Blazor, the UI state is maintained at server side. So you want all client requests to go to the same server, including the SignalR connection. Then you need to enable server sticky mode to `Required` during negotiation:
124
+
For example, when you're using server-side Blazor, the UI state is maintained at the server side. So you want all client requests to go to the same server, including the SignalR connection. Then you need to enable server sticky mode to `Required` during negotiation:
Another way that you can customize negotiation is in multiple endpoints. Because the app server provides the service URL as the negotiation response, the app server can determine which endpoint to return to clients for load balancing and communication efficiency. That is, you can let the client connect to the nearest service endpoint to save traffic cost.
134
+
Another way that you can customize negotiation is in multiple endpoints. Because the app server provides the service URL as the negotiation response, the app server can determine which endpoint to return to clients for load balancing and communication efficiency. That is, you can let the client connect to the nearest service endpoint to save traffic costs.
135
135
136
136
```cs
137
137
// Sample of a custom router
@@ -149,7 +149,7 @@ private class CustomRouter : EndpointRouterDecorator
149
149
returnnull;
150
150
}
151
151
152
-
returnendpoints.FirstOrDefault(s=>s.Name==endpointName&&s.Online) // Get the endpoint with name that matches the incoming request
152
+
returnendpoints.FirstOrDefault(s=>s.Name==endpointName&&s.Online) // Get the endpoint with the name that matches the incoming request
153
153
??base.GetNegotiateEndpoint(context, endpoints); // Fall back to the default behavior to randomly select one from primary endpoints, or fall back to secondary when no primary ones are online
154
154
}
155
155
}
@@ -158,7 +158,7 @@ private class CustomRouter : EndpointRouterDecorator
158
158
Also register the router to dependency injection:
159
159
160
160
```cs
161
-
// Sample of configuring multiple endpoints and dependency injection CustomRouter.
161
+
// Sample of configuring multiple endpoints and dependency injection
0 commit comments