-
Notifications
You must be signed in to change notification settings - Fork 10k
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
SignalR callbacks working on net7.0, not on net9.0 #58485
Comments
It's due to trimming - working in net7.0 with trimming enabled. Broken in net8.0 with trimming enabled Is there any workaround using TrimmerRootAssembly? |
Trimming isn't supported for SignalR in .NET 8. |
@BrennanConroy - yes i've spent 3 days finding that out. Do you know if it's supported in .NET 9? The reason I ask is that with trimming our client facing app is 50mb and without it it's 140mb. publishing a trimmed app with signalr on net8.0 doesn't give any trim warnings. |
Thanks @BrennanConroy . I've linked a repro demonstrating the issue to |
You are still using the 8.0 package... Trimming support was added in the 9.0 version which means you need the 9.0 package. |
Thanks @BrennanConroy - I updated the reference to the latest pre-release. Same issue. |
var builder = new HubConnectionBuilder().WithUrl("...")
.ConfigureLogging(l =>
{
l.AddConsole();
});
builder.Services.Configure<JsonHubProtocolOptions>(o =>
{
o.PayloadSerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default);
});
var connection = builder.Build();
[JsonSerializable(typeof(string))]
internal partial class AppJsonSerializerContext : JsonSerializerContext { } If you turned on logging you would see an error about Json serialization that would point you in the right direction. The above code works if you only want to receive strings, but you can of course change it for your specific app. |
@BrennanConroy Thanks, adding
resolved it. Much appreciated! |
Is there an existing issue for this?
Describe the bug
Updating from net7.0 to net9.0 breaks all callbacks from signalr.
When running this code under net7.0 it works fine, i see "SignalR connection established." followed by messages coming in on "ProcessJSON". I change to net9.0 and I just see "SignalR connection established." - nothing is logged and no messages arrive.
Expected Behavior
Should function exactly the same as net7.0
Steps To Reproduce
See repro project
https://github.com/ispysoftware/sigrtest9/tree/main
The test fails. Change the net runtime from net9.0 to net7,0 in the project file and the test passes
Set Trimming to false and the test passes.
Exceptions (if any)
No response
.NET Version
net9.0
Anything else?
No response
The text was updated successfully, but these errors were encountered: