-
Notifications
You must be signed in to change notification settings - Fork 25.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
configuration doc #7031
configuration doc #7031
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find the internal review link :(
aspnetcore/signalr/configuration.md
Outdated
## JSON/MessagePack Serialization Options | ||
|
||
ASP.NET Core SignalR supports two protocols for encoding messages, JSON and MessagePack. Each protocol has configuration options that can be used to configure serialization. | ||
JSON Serialization Options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"###"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 #'s are a H3 subheading (these under messagepack). Move to H2 (##)?
aspnetcore/signalr/configuration.md
Outdated
ASP.NET Core SignalR supports two protocols for encoding messages, JSON and MessagePack. Each protocol has configuration options that can be used to configure serialization. | ||
JSON Serialization Options | ||
|
||
JSON serialization can be configured on both the Server and .NET Client by providing a delegate to the AddJsonHubProtocol method. The options object received by that delegate has a PayloadSerializedSettings which is a JSON.NET JsonSerializerSettings object that can be used to configure serialization of arguments and return values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing some code markdown and fullstop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSON serialization can be configured on both the Server and .NET Client.
[import snippet]
In the preceding code,
aspnetcore/signalr/configuration.md
Outdated
|
||
JSON serialization can be configured on both the Server and .NET Client by providing a delegate to the AddJsonHubProtocol method. The options object received by that delegate has a PayloadSerializedSettings which is a JSON.NET JsonSerializerSettings object that can be used to configure serialization of arguments and return values | ||
|
||
On the server, add `AddJsonHubProtocol` to the `AddSignalR` call in `ConfigureServices`. Use PascalCase property names instead of the default camelCase names. See the [JSON.NET Documentation](https://www.newtonsoft.com/json/help/html/Introduction.htm) for more details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Use PascalCase property names instead of the default camelCase names."
This sounds like we're telling them to use Pascal always
aspnetcore/signalr/configuration.md
Outdated
options.PayloadSerializerSettings.ContractResolver = | ||
new DefaultContractResolver(); | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra "}"
Move whole code snippet one tab left
aspnetcore/signalr/configuration.md
Outdated
using Microsoft.Extensions.DependencyInjection; | ||
|
||
// When constructing your connection: | ||
var connection = new HubConnectionBuilder(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove ";"
aspnetcore/signalr/configuration.md
Outdated
options.AccessTokenProvider = async () => { | ||
// Get access token and return it. | ||
}; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove ";"
aspnetcore/signalr/configuration.md
Outdated
options.Headers["Foo"] = "Bar"; | ||
options.Cookies.Add(new Cookie(...)); | ||
options.ClientCertificates.Add(...); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove ";"
aspnetcore/signalr/configuration.md
Outdated
.withUrl("url") | ||
.build(); | ||
|
||
// Sets the transport type. Transport types are defined in preceding table |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot the table?
aspnetcore/signalr/configuration.md
Outdated
.build(); | ||
``` | ||
|
||
> ![NOTE] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[!NOTE]
aspnetcore/signalr/configuration.md
Outdated
| `transport` | Specific transport the client should use, or an `ITransport` implementation for a custom transport. | | ||
| `accessTokenFactory` | Called for each HTTP request to set the authorization header or for WebSockets to set the `access_token` query string value. | | ||
| `logMessageContent` | Log the message content when sending and receiving. Disabled by default. | | ||
| `skipNegotiation` | Only use this when `HttpTransportType.WebSockets` is specified. It skips the negotiation step when it not necessary. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"It skips the negotiation step when it not necessary." =>
"It skips the negotiation step when it isn't necessary."
Closing/reopening to force a build to get review link |
@BrennanConroy Internal review is working. |
|
aspnetcore/signalr/configuration.md
Outdated
|
||
## JSON/MessagePack Serialization Options | ||
|
||
ASP.NET Core SignalR supports two protocols for encoding messages, JSON and MessagePack. Each protocol has configuration options that can be used to configure serialization. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
Each protocol has serialization configuration options .
Linke MessagePack to https://msgpack.org/index.html or other appropriate
aspnetcore/signalr/configuration.md
Outdated
|
||
# ASP.NET Core SignalR configuration | ||
|
||
## JSON/MessagePack Serialization Options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sentence case
aspnetcore/signalr/configuration.md
Outdated
ASP.NET Core SignalR supports two protocols for encoding messages, JSON and MessagePack. Each protocol has configuration options that can be used to configure serialization. | ||
JSON Serialization Options | ||
|
||
JSON serialization can be configured on both the Server and .NET Client by providing a delegate to the AddJsonHubProtocol method. The options object received by that delegate has a PayloadSerializedSettings which is a JSON.NET JsonSerializerSettings object that can be used to configure serialization of arguments and return values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The options object received by that delegate has a PayloadSerializedSettings which is a JSON.NET JsonSer
too long, split up.
AddJsonHubProtocol
Code fence all code. Ditto for PayloadSerializedSettings and JsonSerializerSettings
aspnetcore/signalr/configuration.md
Outdated
| Option | Description | | ||
| ------ | ----------- | | ||
| `HandshakeTimeout` | If the client doesn't send an initial handshake message within this time interval, the connection will be closed | | ||
| `KeepAliveInterval` | If the server hasn't sent a message within this interval, a ping message will is sent automatically to keep the connection open | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will is
aspnetcore/signalr/configuration.md
Outdated
| `HandshakeTimeout` | If the client doesn't send an initial handshake message within this time interval, the connection will be closed | | ||
| `KeepAliveInterval` | If the server hasn't sent a message within this interval, a ping message will is sent automatically to keep the connection open | | ||
| `SupportedProtocols` | Protocols supported by this hub. By default, all protocols registered on the server are allowed, but protocols can be removed from this list to disable specific protocols for individual hubs. | | ||
| `EnableDetailedErrors` | If true, sends detailed error messages to the client when exceptions occur. This may contain sensitive data and is `false` by default | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid this
The detailed error messages may ...
aspnetcore/signalr/configuration.md
Outdated
|
||
### HttpConnectionDispatcherOptions | ||
|
||
Options related to the transport layer. Use these to restrict the transports that can be used by SignalR clients, as well as to configure advanced settings related to memory buffer management. These options are configured by passing a delegate to `MapHub<T>`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Options related to the transport layer.
That doesn't make sense by itself. SHould it be
HttpConnectionDispatcherOptions - Options related to the transport layer.
aspnetcore/signalr/configuration.md
Outdated
| Cookies | Cookies to be sent with each HTTP request. | | ||
| ClientCertificates | TLS client certificates to send when connecting over HTTP (not supported in Xamarin) | | ||
|
||
The following code samples demonstrate the C# setting connection options with the `HubConnectionBuilder`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following code sets connection options with the HubConnectionBuilder
:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aspnetcore/signalr/configuration.md
Outdated
} | ||
``` | ||
|
||
### HttpConnectionDispatcherOptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
append Options related to the transport layer ???
aspnetcore/signalr/configuration.md
Outdated
|
||
### HttpConnectionDispatcherOptions | ||
|
||
Options related to the transport layer. Use these to restrict the transports that can be used by SignalR clients, as well as to configure advanced settings related to memory buffer management. These options are configured by passing a delegate to `MapHub<T>`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is these?
aspnetcore/signalr/configuration.md
Outdated
|
||
| Option | Description | | ||
| ------ | ----------- | | ||
| `ApplicationMaxBufferSize` | The maximum number of bytes the connection (transport) can buffer when invoking methods from the client, before blocking and waiting for the application to consume enough bytes to allow writing again. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try to split up long sentence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments. Still working through it
aspnetcore/signalr/configuration.md
Outdated
|
||
[!code-csharp[Startup config](configuration/sample/config-startup.cs?range=1-5)] | ||
|
||
The preceding code adds add `AddJsonHubProtocol` to the [AddSignalR](/dotnet/api/microsoft.extensions.dependencyinjection.signalrdependencyinjectionextensions.addsignalr#Microsoft_Extensions_DependencyInjection_SignalRDependencyInjectionExtensions_AddSignalR_Microsoft_Extensions_DependencyInjection_IServiceCollection_) call in [ConfigureServices](/dotnet/api/microsoft.aspnetcore.hosting.istartup.configureservices#Microsoft_AspNetCore_Hosting_IStartup_ConfigureServices_Microsoft_Extensions_DependencyInjection_IServiceCollection_). Then the code provides a delegate to the `AddJsonHubProtocol` method. The `options` object received by that delegate has a `PayloadSerializedSettings`. The `PayloadSerializedSettings` is a JSON.NET [JsonSerializerSettings](/dotnet/api/microsoft.aspnetcore.mvc.formatters.jsonserializersettingsprovider object that can be used to configure serialization of arguments and return values. See the [JSON.NET Documentation](https://www.newtonsoft.com/json/help/html/Introduction.htm) for more details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wording here seems a bit awkward. What about moving it above the example:
JSON serialization can be configured on the server using the AddJsonProtocol
extension method. The AddJsonProtocol
method takes a delegate that receives an options
object. The PayloadSerializerSettings
property on that object is a JSON.NET JsonSerializerSettings object that can be used to configure serialization of arguments and return values. See the JSON.NET Documentation for more details.
As an example, you can configure the serializer to use PascalCase
names instead of the default camelCase
names using the following code:
[example]
In the .NET client, the same AddJsonHubProtocol
extension method exists on HubConnectionBuilder. The Microsoft.Extensions.DependencyInjection
namespace must be imported to resolve the extension method:
[example]
aspnetcore/signalr/configuration.md
Outdated
The preceding code adds add `AddJsonHubProtocol` to the [AddSignalR](/dotnet/api/microsoft.extensions.dependencyinjection.signalrdependencyinjectionextensions.addsignalr#Microsoft_Extensions_DependencyInjection_SignalRDependencyInjectionExtensions_AddSignalR_Microsoft_Extensions_DependencyInjection_IServiceCollection_) call in [ConfigureServices](/dotnet/api/microsoft.aspnetcore.hosting.istartup.configureservices#Microsoft_AspNetCore_Hosting_IStartup_ConfigureServices_Microsoft_Extensions_DependencyInjection_IServiceCollection_). Then the code provides a delegate to the `AddJsonHubProtocol` method. The `options` object received by that delegate has a `PayloadSerializedSettings`. The `PayloadSerializedSettings` is a JSON.NET [JsonSerializerSettings](/dotnet/api/microsoft.aspnetcore.mvc.formatters.jsonserializersettingsprovider object that can be used to configure serialization of arguments and return values. See the [JSON.NET Documentation](https://www.newtonsoft.com/json/help/html/Introduction.htm) for more details. | ||
|
||
> [!NOTE] | ||
> It's possible to use PascalCase property names instead of the default camelCase names. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems awkward. There are many different settings and while this is a common one, I don't think it should be called out as a NOTE. In my above comment, I suggested just working it in to the example description. I think that's a little cleaner.
aspnetcore/signalr/configuration.md
Outdated
|
||
### Configure [HubOptions](/dotnet/api/microsoft.aspnetcore.signalr.huboptions) for SignalR | ||
|
||
The following table describes the `HubOptions` options for configuring the hub: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for configuring the a hub
aspnetcore/signalr/configuration.md
Outdated
| `SupportedProtocols` | Protocols supported by this hub. By default, all protocols registered on the server are allowed, but protocols can be removed from this list to disable specific protocols for individual hubs. | | ||
| `EnableDetailedErrors` | If true, sends detailed error messages to the client when exceptions occur. The detailed error messages may contain sensitive data, and are `false` by default. | | ||
|
||
The `HubOptions` are configured in the `ConfigureServices` method of the `Startup` class, as shown in the following code sample: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest:
Options can be configured for all hubs by providing an options delegate to the AddSignalR
call in ConfigureServices
aspnetcore/signalr/configuration.md
Outdated
|
||
[!code-csharp[Startup](configuration/sample/config-startup.cs?range=7-14)] | ||
|
||
Strongly-typed [HubOptions<T>](/dotnet/api/microsoft.aspnetcore.signalr.huboptions-1) are as follows: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest:
Options for a single hub override the global options provided in AddSignalR
and can be configured using AddHubOptions<T>
:
edbc7f1
to
79f0c5e
Compare
aspnetcore/signalr/configuration.md
Outdated
> [!NOTE] | ||
> It's not possible to configure JSON or MessagePack serialization in the JavaScript client at this time. | ||
|
||
### Configure [HubOptions](/dotnet/api/microsoft.aspnetcore.signalr.huboptions) for SignalR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make all these headers a little more consistent. How about we remove the type names from the headers, and leave those for the prose below.
Also, I think we can just merge this with the next section (HttpConnectionDispatcherOptions
) as a "Configuring Server Options" section. The section below on the Client has multiple types and I think it works fine there.
aspnetcore/signalr/configuration.md
Outdated
|
||
Items in the table marked with an asterisk (*) are specific to WebSockets. | ||
|
||
### HubConnectionBuilder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Configuring Client Options"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section looks really rough right now. I think we should split it into two, with one for .NET and one for JavaScript. There will be some duplication, but I think that's OK.
In each section, I think we should list the properties on the relevant object (JS: https://github.com/aspnet/SignalR/blob/dev/clients/ts/signalr/src/IHttpConnectionOptions.ts, C#: https://github.com/aspnet/SignalR/blob/dev/src/Microsoft.AspNetCore.Http.Connections.Client/HttpConnectionOptions.cs) with the descriptions we've got here. Code samples can come afterwards, illustrating some of the scenarios.
aspnetcore/signalr/configuration.md
Outdated
|
||
### HubConnectionBuilder | ||
|
||
The [HubConnectionBuilder](/dotnet/api/microsoft.aspnetcore.signalr.client.hubconnectionbuilder) API is available for both C# and TypeScript clients. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TypeScript JavaScript
The client is written in TypeScript and includes a full set of "typings" files to make it easier to use from TypeScript, but that's just an implementation detail. The client works on any JavaScript environment and you can use plain JavaScript to interact with it, so it's a "JavaScript client"
| `WebSockets`* | Gets the WebSockets options object. | | ||
| `CloseTimeout`* | TimeSpan to set how long to wait for a clean WebSocket close when connection is being terminated. | | ||
| `SubProtocolSelector`* | A delegate the hub calls and passes a list of `Sec-WebSocket-Protocol` values from the request header. A delegate returns the chosen `Sec-WebSocket-Protocol`. | | ||
| `AccessTokenProvider`* | A delegate that is called to get an access token. The token is applied as an HTTP Bearer Authentication header. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First: AccessTokenProvider
isn't a property on HttpConnectionDispatcherOptions
. Just strike this row.
Also: It's not quite clear that CloseTimeout
, and SubProtocolSelector
are properties on the WebSocketOptions
object, not HttpConnectionDispatcherOptions
. Perhaps a separate table? Or write them as WebSockets.CloseTimeout
?
|
||
Items in the table marked with an asterisk (*) are specific to WebSockets. | ||
|
||
## Configure client options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the client options section needs a bit of a rework. The headers don't match with the tables and the code snippets are a bit rough. I'll sketch something up.
@Rick-Anderson Can you clarify the expected pattern here? In most of the other docs it looks like inline snippets are used when the example is illustrative but not part of a fully-functional sample and imported snippets are used when the example is part of a fully-functional sample. There isn't a sample associated with this document so I'd expect to use mostly inline snippets in this document. |
title: ASP.NET Core SignalR configuration | ||
author: rachelappel | ||
description: Configure ASP.NET Core SignalR Apps | ||
manager: wpickett |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the following metadata fields:
- manager
- ms.prod
- ms.technology
- ms.topic
These are defined in docfx.json now.
|
||
[!code-csharp[HubConnectionBuilder](configuration/sample/addhubjsonprotocol.cs)] | ||
|
||
### MessagePack Serialization Options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Serialization Options --> serialization options
I reworked the client options section, but I realized the original branch is in a fork so I can't easily just push some additional changes :). The easiest thing to do here may just be to open a new PR (again 😝) from my branch now. |
@anurse Go for it, remember to tag us. :D I'll hold off on any changes on my side until you do that. |
As discussed #7031 (comment) I made some changes and decided to just open a new PR to get things cleared up. [Internal Review URL](https://review.docs.microsoft.com/en-us/aspnet/core/signalr/configuration?view=aspnetcore-2.1&branch=pr-en-us-7199)
fixes #6599
The PR at #6852 kept erroring when pushing despite fixing merge messages, so I moved it here rather than continue to fight with it for no reason.
Internal review