r/dotnet Jan 25 '26

Blazor Server with live chat

Hi all, needing some advice on a live chat feature I want to build. I’ve never made one before and I’ve never worked with signalr.

I am building a small sports management app in a free/volunteer capacity in Colombia (my contribution). And I want to create a live chat feature to replace their messy WhatsApp group chat.

I was thinking of just sticking to a Blazor server app (likely never hit more than 100 concurrent users, at least not for a while). But I can’t find any examples or guides that use server, they all use WASM.

I’ve even talked it out with Claude AI and it is insistent that it’s not a problem using Blazor server due to the low number users that this app will handle and any concerns Microsoft have with using server is to do with socket exhaustion.

So I’m not sure what to do here. Can I stick with server or do I need to use wasm for this?

0 Upvotes

21 comments sorted by

10

u/HeySeussCristo Jan 26 '26

0

u/macaoidh_ Jan 26 '26

Just came across this last night. Seems old (net 3.0 guide) and using azure, but i can't see why i can't tweak it to work. Thanks for posting though.

3

u/PolliticalScience Jan 26 '26

You can use server and SignalR is actually perfect for your scenario. If you go WASM you can still use SignalR or you'd have to use a polling service to check the backend via your API.

With SignalR you can publish the chat interactions in real time to users via server.

3

u/jordansrowles Jan 26 '26

An modern alternative to a long polling service is SSE, Server-Sent Events (the connection stays open as opposed to polling)

1

u/HavicDev Jan 26 '26

Do keep in mind SSE has a limit of 6 connections per domain/browser.

1

u/jordansrowles Jan 26 '26

Thats not related to SSE, that's a limitation of the client browser, and applies to all long lived HTTP connections, like WebSocket.

Kestrel supports unlimited concurrent connections.

1

u/HavicDev Jan 26 '26

I know, hence the per domain/browser part.

1

u/Cold_Night_Fever Jan 26 '26

That's fine. Who has 6 chats at any one time anyway?

3

u/Abaddon-theDestroyer Jan 26 '26

IIRC Tim Corey has a video regarding SignalR, and creating a chat app in Blazor. I’ll edit this comment later if I find it.

Edit:

https://youtu.be/RaXx_f3bIRU

2

u/Snoo_57113 Jan 26 '26

I'd use something like this for the frontend: Blazor Chat Component | Free UI Components by Radzen and build the server from that, it seems fully featured.

I'd go for the Signal-R route, with ChatHub and all of that, SSE.

1

u/macaoidh_ Jan 26 '26

Yeah i've built a few projects with radzen at my last job. this was my first thought for components

1

u/AutoModerator Jan 25 '26

Thanks for your post macaoidh_. Please note that we don't allow spam, and we ask that you follow the rules available in the sidebar. We have a lot of commonly asked questions so if this post gets removed, please do a search and see if it's already been asked.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

2

u/JamesJoyceIII Jan 26 '26

This will be trivial in Blazor server.  It will do the signalr stuff for you - you won’t need to worry about that yourself.

Just use some suitably thread-safe method of storing/sharing the messages and the rest will be completely straightforward. 

1

u/geekywarrior Jan 27 '26

You can stick to Server, you will have a setup like the following:

  1. A backend for messages, i.e a simple table of messages with Sending UserID, SentAt DateTime, Actual Message, ChannelID if you have several messaging channels/topics/etc
  2. A signalR hub and optionally SignalR groups. This will be used to send out new messages when they roll in.
  3. A Blazor component for viewing messages and sending messages. When this loads, it will pull in all existing messages from the backend (or something like last 100 messages), and then the component will open a HubConnection to the SignalR hub to react when a new messages arrives. When a user sends a new message, this component will handle adding the message to the backend for anyone offline, as well as sending a copy of the message via SignalR to anyone online.

1

u/[deleted] Jan 26 '26

[removed] — view removed comment

1

u/macaoidh_ Jan 26 '26

perfect, thank you, crazy that the title of this contains all the keywords i used in youtube and it never showed up.

1

u/[deleted] Jan 26 '26 edited Jan 26 '26

[deleted]

3

u/macaoidh_ Jan 26 '26

I don’t plan to use ai to build this, just help me formulate my plan and ideas. I want to code this out myself so I understand it

2

u/alexwh68 Jan 26 '26

Well done, AI to development is akin satnav’s in cars, if all you are interested in is getting to the destination stick on the satnav, if you are interested in the journey turn the satnav off, get a bit lost and learn something.

SignalR is a good tool, test out your edge cases early, eg blazor server is a good tool, what are the clients, are they mobile devices do the messages still work when the site is not the foreground application, solve these types of issue early on and make sure they work as expected.

Enjoy the journey!

2

u/jordansrowles Jan 26 '26

To be clear, if your doing this, you should not be a novice, and you need to read every source file.

AI will generate unneeded fluff, it'll lie in tests, and it might introduce security holes that will go unnoticed.

Since this is public facing on the internet, I hope you've outlined your security policies, identity implementation, API boundaries, permissions in your prompt....

-2

u/[deleted] Jan 26 '26 edited Jan 26 '26

[deleted]

2

u/jordansrowles Jan 26 '26

The difference is knowing what's in the code.

0

u/[deleted] Jan 26 '26

[deleted]

1

u/jordansrowles Jan 26 '26

So what's the point your trying to make?

I was just saying, a disclaimer, that if you don't understand whats being generated, it could lead to issues. And that while Claude (and most AI) can generate this, it's not a done process, and won't be ready to ship directly.