8

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.

Jason D
  • 1,863
  • 2
  • 16
  • 30
  • I've just run 10 tabs on my internal network and accessed different pages to ensure the queries as still working - all good. I am running Google Chrome 84.0.4147.135, the site is hosted on IIS10. What's your configuration? – DGrowns Sep 02 '20 at 07:02
  • I am running Chrome 84.0.4147.105 on Windows 10 client. I also saw the same problem with Firefox. The server is IIS 10 running on Server 2016 – Jason D Sep 02 '20 at 10:41
  • Odd. When it does not render, does it give an HTTP error back? What does dev tools show? – DGrowns Sep 02 '20 at 14:07
  • DGrowns, just checking are you using Blazor server or wasm? – Jason D Sep 03 '20 at 00:35
  • Blazor server, we need windows authentication so wasm was not an option for us. – DGrowns Sep 03 '20 at 07:27

1 Answers1

9

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.

DGrowns
  • 406
  • 2
  • 8
  • DGrowns you are the man! I tried as you suggested and it works great. Thank you so much!!! – Jason D Sep 04 '20 at 17:37
  • 1
    I just dealt with something similar yesterday with iframes, and the fix was exactly the same. Had I found this answer yesterday, I could have saved so much time. Further details for anyone else reading this: Chrome limits requests to 6 to the same host/site, but websockets have their own, much higher, limit. If you do not have websockets installed and enabled in IIS, Blazor Server will fall back to one perpetual POST or GET request for each tab or iframe running your app, potentially severely limiting your app's ability to communicate with the server. – Daniel Aug 10 '22 at 14:17