Skip to content

Commit

Permalink
Reduce SignalR buffer size and max message size. Check for duplicate …
Browse files Browse the repository at this point in the history
…session ID.
  • Loading branch information
bitbound committed Jul 29, 2021
1 parent a4a6fd4 commit f570b8a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Agent.Installer.Win/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ private async Task ExtractDeviceInitInfo()
if (Guid.TryParse(guid, out _))
{
OrganizationID = guid;
return;
break;
}


Expand Down
18 changes: 12 additions & 6 deletions Server/Hubs/CasterHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,22 @@ public IceServerModel[] GetIceServers()
public Task GetSessionID()
{
var random = new Random();
var sessionID = "";
for (var i = 0; i < 3; i++)
var sessionId = "";

while (string.IsNullOrWhiteSpace(sessionId) ||
SessionInfoList.ContainsKey(sessionId))
{
sessionID += random.Next(0, 999).ToString().PadLeft(3, '0');
for (var i = 0; i < 3; i++)
{
sessionId += random.Next(0, 999).ToString().PadLeft(3, '0');
}
}
Context.Items["SessionID"] = sessionID;

Context.Items["SessionID"] = sessionId;

SessionInfoList[Context.ConnectionId].AttendedSessionID = sessionID;
SessionInfoList[Context.ConnectionId].AttendedSessionID = sessionId;

return Clients.Caller.SendAsync("SessionID", sessionID);
return Clients.Caller.SendAsync("SessionID", sessionId);
}

public Task NotifyRequesterUnattendedReady(string browserHubConnectionID)
Expand Down
20 changes: 4 additions & 16 deletions Server/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void ConfigureServices(IServiceCollection services)
services.AddSignalR(options =>
{
options.EnableDetailedErrors = IsDev;
options.MaximumReceiveMessageSize = 500_000;
options.MaximumReceiveMessageSize = 100_000;
})
.AddJsonProtocol(options =>
{
Expand Down Expand Up @@ -242,21 +242,9 @@ public void Configure(IApplicationBuilder app,

app.UseEndpoints(endpoints =>
{
endpoints.MapHub<AgentHub>("/AgentHub", options =>
{
options.ApplicationMaxBufferSize = 500_000;
options.TransportMaxBufferSize = 500_000;
});
endpoints.MapHub<CasterHub>("/CasterHub", options =>
{
options.ApplicationMaxBufferSize = 100_000;
options.TransportMaxBufferSize = 100_000;
});
endpoints.MapHub<ViewerHub>("/ViewerHub", options =>
{
options.ApplicationMaxBufferSize = 100_000;
options.TransportMaxBufferSize = 100_000;
});
endpoints.MapHub<AgentHub>("/AgentHub");
endpoints.MapHub<CasterHub>("/CasterHub");
endpoints.MapHub<ViewerHub>("/ViewerHub");

endpoints.MapControllers();
endpoints.MapBlazorHub();
Expand Down

0 comments on commit f570b8a

Please sign in to comment.