Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blazor Server # of connections per use is limited by the browser

I am in the process of building a Blazor Server-Side database application.

One of my requirements is that the user can open each website page in a different tab.

I have found that after 5 tabs are opened, any new pages are blocked from rendering. If I close one page, then the 6th page can render. Apparently this is due to the fact that browsers can support a limited number of SignalR connections at one time. I have read the limit for Chrome is 6 at a time (although I can only get 5 working).

Error Messages in Chrome:

Error: Connection disconnected with error 'Error: Server returned handshake error: Handshake was canceled.'

Error: Error: Server returned handshake error: Handshake was canceled.

Uncaught (in promise) Error: Cannot send data if the connection is not in the 'Connected' State.
    at e.send (blazor.server.js:1)

Is there a solution for this problem? Or do I need to explore porting to Blazor Client?

I found the following article about this topic but not sure it it can be applied to a Blazor application: SignalR and Browser Connection limit

It's a little scary as I have already built quite a bit of code, and don't want to spend too much time trying to hack a workaround.

like image 596
Jason D Avatar asked Sep 01 '20 18:09

Jason D


1 Answers

I finally managed to replicate it on my internal network, it seems to have been resolved now that I have installed WebSockets.

  1. Open Server Manager
  2. Open Add Roles and Features
  3. Expand WebServer (IIS)
  4. Expand Application Development
  5. Select WebSocket Protocol

After installing this, I opened 20 tabs of my blazor server application, each one on a different page and the issue did not re-occur (I also did a couple of refreshes on each to be sure).

I came across this after reading

Blazor works best when using WebSockets as the SignalR transport due to lower latency, reliability, and security. Long Polling is used by SignalR when WebSockets isn't available or when the app is explicitly configured to use Long Polling.

From the Blazor docs.

like image 69
DGrowns Avatar answered Nov 13 '22 12:11

DGrowns