Best practices for implementing Notifications and Streaming (Gen AI-enabled chats) in Blazor Web App

Manoj Ganapathi 0 Reputation points
2025-01-11T13:56:34.58+00:00

Need some architectural guidance.

I am building a B2C solution using Blazor Web App model. The entire stack is C# and runs on Azure. I am just trying to understand some best practices for integrating the following capabilities:

  1. Push Notifications (pushed through Azure Web PubSub)
  2. Streaming of Chat responses (in a Gen AI based ChatBot)

The broad questions relating to the above:

  1. Choice of Interactive mode for each of the above scenarios. The Blazor samples for Web PubSub are purely in WASM, but can I just carry that logic to Web Apps? Any other consideration to keep in mind (other than scaling the units on the PubSub service side in Azure).
  2. Can I pool Web Socket connection effectively across these scenarios (considering that Interactive Server mode also needs one).

Is EShop the reference I can use for patterns related to my context? Any other references?

Thanks in Advance!

Azure Web PubSub
Azure Web PubSub
An Azure service that provides real-time messaging for web applications using WebSockets and the publish-subscribe pattern.
82 questions
Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,654 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 69,976 Reputation points
    2025-01-13T22:31:25.7833333+00:00
    1. if you use blazor server interactive mode, then the server app creates a dedicated client session and signal/r hub for each client connection. this server session would then become a websocket client to the push notification app, so the blazor app would have 2 websocket connections for each client. As chat api calls are typically a REST api call, the Blazor code would just make webclient call and update the UI chat log (it not really a peer to peer chat, but a UI that looks like one). the Gen AI server is stateless, you re-send all the desired context data (say chat history) with each request.
    2. web socket pooling is to handle client reconnects to the same peer. the connection is not closed, but returned to the pool. this only makes sense if the client initiates all the traffic, as there is no reciever while in the pool.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.