✅ SignalR Not working
this is a signalr for frontend generated by ai but even this or my own doesnt work, ports are correct connection is made _hubConnection state prints Connected, but when i click button Send with a message nothing happens, other buttons work, Console.WriteLine("EEE"); never prints i need help, the backend is good i have mapped the /chathub and ports are correct i have a frontend web app server and a core web api backend
63 Replies
hm, so to tackle this issue, the first thing i would do is setup logging on the signalr client
you can do that via the connection builder like this
Either use your applications dependency injected logger, or just configure a new logger factory
e.g.
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
okay thank you
i have tried from several docs, youtube videos and ai generated from more than 3+, but for some reason, sometimes it doesnt work, now i made again a sepperate blazor web app server without and added what needed, the connection gets created i have added console.write inn each step, the message is send, received but i triggered the send method inside the onInitialize, something goes wrong with the ui, and i cant click buttons neither the deafult ones counter.razor, it like stops working for some reason but the message is received and printed, and the big problem comes when i try connecting with multiple backend server using a load balancer (nginx) with docker, where i put for the .WithUrl in hubcon, the nginx localhost:8080/chathub, but still it cant connect even though everything is correct
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
okay so first of all, i would also suggest what tebeco suggested, make a minimal plain web javascript client to learn about signalr
also your issue with the UI not working anymore, that is probably due to a runtime error in the browser, meaning there is probably an exception being thrown in the blazor code, you can check that via the browser consol (technically i can also see this happening when there is an exception being thrown on the server when interactive server is being used, which also is using signalr btw!)
then about a load balancer / reverse proxy and having multiple instances of your app running, for the blazor part i would assume you need to enable sticky sessions, atleast when using interactive server, wasm shouldnt matter since its just serving static files i think?
For signalr however (assuming we are using websocket), using sticky sessions would also work, however you can get around doing that by skipping the signalr negotiation. This would make it directly connect to the websocket without the prior negotiation request.
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
if i want to work on top of the blazor, should i change from web app to web assembly?
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
@page "/"
@using Microsoft.AspNetCore.SignalR.Client
@inject NavigationManager NavManager
<div class="form-group"> <label> User: <input @bind="userInput"></input> </label> <label> Message: <input @bind="messageInput"></input> </label> </div> <button @onclick="Send">Send</button> <hr /> <ul> @foreach (var message in messages) { <li>@message</li> } </ul> @code { private HubConnection? hubConnection; private List<string> messages = new(); private string? userInput; private string? messageInput; protected override async Task OnInitializedAsync() { Console.WriteLine("Start"); hubConnection = new HubConnectionBuilder() .WithUrl(NavManager.ToAbsoluteUri("/chathub")) .WithAutomaticReconnect() .Build(); Console.WriteLine("Builded"); hubConnection.On<string, string>("ReceiveMessage", (user, message) => { Console.WriteLine("RECEIVED"); var formattedMessage = $"{user}: {message}"; Console.WriteLine(formattedMessage); InvokeAsync(() => { messages.Add(formattedMessage); StateHasChanged(); }); }); await hubConnection.StartAsync(); Console.WriteLine("Started the con"); Console.WriteLine(hubConnection.State); await Send(); } private async Task Send() { Console.WriteLine("Send"); Console.WriteLine(hubConnection?.State); if (hubConnection is not null) { await hubConnection.SendAsync("SendMessage", "Maria", "Hello"); } } public bool IsConnected => hubConnection?.State == HubConnectionState.Connected; } in this base example in blazor, i have added a trigger on initialize cause buttons dont work neither the default counter one, the connection is made, the message is send and received and printed but ui not responsive
<div class="form-group"> <label> User: <input @bind="userInput"></input> </label> <label> Message: <input @bind="messageInput"></input> </label> </div> <button @onclick="Send">Send</button> <hr /> <ul> @foreach (var message in messages) { <li>@message</li> } </ul> @code { private HubConnection? hubConnection; private List<string> messages = new(); private string? userInput; private string? messageInput; protected override async Task OnInitializedAsync() { Console.WriteLine("Start"); hubConnection = new HubConnectionBuilder() .WithUrl(NavManager.ToAbsoluteUri("/chathub")) .WithAutomaticReconnect() .Build(); Console.WriteLine("Builded"); hubConnection.On<string, string>("ReceiveMessage", (user, message) => { Console.WriteLine("RECEIVED"); var formattedMessage = $"{user}: {message}"; Console.WriteLine(formattedMessage); InvokeAsync(() => { messages.Add(formattedMessage); StateHasChanged(); }); }); await hubConnection.StartAsync(); Console.WriteLine("Started the con"); Console.WriteLine(hubConnection.State); await Send(); } private async Task Send() { Console.WriteLine("Send"); Console.WriteLine(hubConnection?.State); if (hubConnection is not null) { await hubConnection.SendAsync("SendMessage", "Maria", "Hello"); } } public bool IsConnected => hubConnection?.State == HubConnectionState.Connected; } in this base example in blazor, i have added a trigger on initialize cause buttons dont work neither the default counter one, the connection is made, the message is send and received and printed but ui not responsive
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif in chat
For longer snippets, use: https://paste.mod.gg/$code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif in chat
For longer snippets, use: https://paste.mod.gg/$codegif
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
in this base example in blazor, i have added a trigger on initialize cause buttons dont work neither the default counter one, the connection is made, the message is send and received and printed but ui not responsive
finaly
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
its the bare minimum example
i was talking at start
[2025-10-29T16:40:16.787Z] Error: Connection disconnected with error 'Error: Server returned an error on close: Connection closed with an error.'.
log @ blazor.web.js:1
_stopConnection @ blazor.web.js:1
(anonymous) @ blazor.web.js:1
_close @ blazor.web.js:1
stop @ blazor.web.js:1
_stopInternal @ blazor.web.js:1
await in _stopInternal
stop @ blazor.web.js:1 _processIncomingData @ blazor.web.js:1 (anonymous) @ blazor.web.js:1 (anonymous) @ blazor.web.js:1 blazor.web.js:1 Uncaught (in promise) Error: Server returned an error on close: Connection closed with an error. at gn._processIncomingData (blazor.web.js:1:60595) at xn.onreceive (blazor.web.js:1:53760) at WebSocket.<anonymous> (blazor.web.js:1:81866) _processIncomingData @ blazor.web.js:1 (anonymous) @ blazor.web.js:1 (anonymous) @ blazor.web.js:1 these popped up in the console
stop @ blazor.web.js:1 _processIncomingData @ blazor.web.js:1 (anonymous) @ blazor.web.js:1 (anonymous) @ blazor.web.js:1 blazor.web.js:1 Uncaught (in promise) Error: Server returned an error on close: Connection closed with an error. at gn._processIncomingData (blazor.web.js:1:60595) at xn.onreceive (blazor.web.js:1:53760) at WebSocket.<anonymous> (blazor.web.js:1:81866) _processIncomingData @ blazor.web.js:1 (anonymous) @ blazor.web.js:1 (anonymous) @ blazor.web.js:1 these popped up in the console
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
yes, did see that before, never looked into sub protocols like that before though :D
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
I think this is the most important point here. Why do you want to use blazor and make a signalr connection? In web assembly it would make sense, if your not doing blazor wasm, than this doesnt make much sense unless your using a different service's signalr hub, which from the looks of it, you arent doing?)
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
yeee
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
i was told to start with blazor web app server for frontend,
the goal:
Please don't upload any potentially harmful files @Banylog, your message has been removed
i cant
upload
a picture
pdf
you sent a pdf
yes
1 sec
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
i send picture 1 sec
goal is to make a full stack chat app using .net c#
with load balancer
2 databases
mysql, mongodb
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
i have done all except this signalr cause this errors
interesting choice first of all
your atleast gonna need one more "database" for a backplane for signalr if you want to have your backend be "multi" instances
(assuming thats what you mean when talking about using lb's)
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
oh yeah
i forgot
ye, redis is my to go to aswell for that
i have redis
for caching/
for the signalr
but signalr problems
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
yeah i know
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
signalr uses redis for its pub/sub
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
chat application
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
what you mean
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
i think so too yes, you need to understand both signalr and blazor independently first. im assuming tebeco is gonna explain the interactivity models now
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
oh show i should use blazor web assembly cause its client side?
so*
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
okay thanks for the help, i appreciate it
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
BleepingComputer
Microsoft: DNS outage impacts Azure and Microsoft 365 services
Microsoft is suffering an ongoing DNS outage affecting customers worldwide, preventing them from logging into company networks and accessing Microsoft Azure and Microsoft 365 services.
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
thanks a lot
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
If you have no further questions, please use /close to mark the forum thread as answered
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
$close
If you have no further questions, please use /close to mark the forum thread as answered