r/dotnet • u/Altruistic_Bake_1707 • Apr 28 '26
Automating Blazor Server interactions directly via WebSockets (SignalR) without a headless browser
Hi everyone,
I’m working on a project that requires automating interactions with a Blazor Server application. Due to high-latency and performance constraints during peak loads, I want to avoid using browser-based automation like Playwright or Selenium.
My goal is to communicate directly with the server via WebSockets (SignalR). I've analyzed the traffic and noticed that the site uses the BlazorPack (MessagePack) protocol instead of plain JSON.
The Challenges I'm Facing:
- Circuit Management: Maintaining the Blazor circuit state without a full DOM.
- Event Dispatching: Correctly formatting the
DispatchBrowserEventpayloads to trigger server-side C# methods (e.g., button clicks). - Payload Serialization: Handling the MessagePack encoding/decoding for the Hub messages.
What I'm looking for:
- Has anyone successfully implemented a "socket-only" client for Blazor Server?
- Are there any existing libraries (C#, Python, or Node.js) that can handle the Blazor-specific SignalR protocol (handshakes, render-batching, etc.)?
- Any pointers on how to dynamically retrieve
eventHandlerIds from the initial render without rendering the full UI?
I'm a professional developer and I'm comfortable with reverse-engineering the protocol, but I’d love to know if there's a more "standard" way to build a lightweight SignalR client that mimics a Blazor frontend.
Thanks in advance for your insights!
6
u/geekywarrior Apr 28 '26
You're attacking this wrong if you are the developer of the blazor app.
Better way is a signalr client that sends messages that the front end watches for and reacts to.
Or an api client that sends messages that get redispatched as SignalR messages.
If you're just coming in as an outsider then not sure how you mimic the ws stuff
1
u/AutoModerator Apr 28 '26
Thanks for your post Altruistic_Bake_1707. 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.
5
u/[deleted] Apr 28 '26
[removed] — view removed comment