I am developing an application on ASP.NET Core Blazor. The application has authorization via cookies. The application uses SignalR to send messages between users.
The application works successfully locally on regular Windows hosting.
As soon as I published the application on VPS, messages stopped being sent and an error appeared:
[2025-06-02T13:17:04.432Z] Error: System.IO.InvalidDataException: Invalid negotiation response received.
System.Text.Json.JsonReaderException: '<' is an invalid start of a value. LineNumber: 1 | BytePositionInLine: 0.
at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
In the same project, I use my hubs via JS and they work. As soon as I try to use them via C#, I get this error.
Here is an example of the connection:
hubConnection = new HubConnectionBuilder() .WithUrl(_navigationManager.ToAbsoluteUri("/chathub"), e => { e.UseDefaultCredentials = true; }) .Build();I have already configured many things, but nothing helps:
- Web sockets are definitely open
- I tried using the allow anonymous attribute for hubs
- I published a simpler project without authorization, and everything works there
Perhaps you have encountered this before, thank you for your answers.