Search⌘ K

HTTP Transport Configuration

Explore how to configure HTTP transport options in SignalR within ASP.NET Core. Understand settings like transport types, buffer sizes, authentication expiration behavior, and timeouts to optimize the performance and security of your real-time applications.

Background

We'll now locate the line that contains app.MapHub and replace it with the following code:

C#
app.MapHub<LearningHub>("/learningHub", options =>
{
options.Transports =
HttpTransportType.WebSockets |
HttpTransportType.LongPolling;
options.CloseOnAuthenticationExpiration = true;
options.ApplicationMaxBufferSize = 65_536;
options.TransportMaxBufferSize = 65_536;
options.MinimumProtocolVersion = 0;
options.TransportSendTimeout = TimeSpan.FromSeconds(10);
options.WebSockets.CloseTimeout = TimeSpan.FromSeconds(3);
options.LongPolling.PollTimeout = TimeSpan.FromSeconds(10);
Console
.WriteLine($"Authorization data items: {options.AuthorizationData.Count}");
});

Applying advanced transport configuration

These are the options where you apply transport settings. Let’s now examine these settings one by one.

  • Transports: This setting allows us to set the availability of SignalR transport mechanisms. By default, it supports WebSocket, long polling, and ...