10

It is impossible to use SignalR, when several tabs opened with unique ids assigned to each tab (see. When SignalR made 8-10 connections at a time live chat doesn't work).

But. there is a workaround I described in this stackoverflow issue. The idea is to overwrite connectionid in order, that every opened tab would have the same connection id: thus, logicaly, in my particular case, there is no reason to have unique ids for each tab, 'cos each tab is opened by one MyApplicationUserId.

Anyway, it has been noticed in stackoverflow (see SignalR How is a duplicate Connection Id handled? ), that connectionid must be unique. And they say, that IConnectionIdGenerator will be removed in an upcomming release.

So, this is a kind of blind alley. I must use unique ids, but I cannot use SignalR with several browser tabs opened.

Thank you. Dmitry.

Community
  • 1
  • 1
Dmitry
  • 661
  • 5
  • 21

3 Answers3

12

As has been discussed in the SignalR issue you've opened here, most modern browsers limit the maximum number of concurrent connections (typically around 6) to the same site.

One workaround is to use subdomains, i.e. each tab connects to a different subdomain (this is the approach Facebook is using). Another option would be to start just one connection and use localStorage as a message bus between tabs as suggested by FreshCode in this question: SignalR and Browser Connection limit

Community
  • 1
  • 1
Alexander Köplinger
  • 2,497
  • 17
  • 15
  • Hm.. I created dublicated subdomain in IIS8, thus I have: im.domain.com, im2.domain.com. And I load scripts from im and im2 subdomains, and open connecion to them, mixing in such way, that 4 chrome tabs opened with loaded scripts from im, and 4 tabs with scripts from im2. and connection.url I set in the same way. But anyway, I cannot make more then 6 tabs work... :( – Dmitry Oct 26 '12 at 13:23
  • Interesting, the two subdomains should be treated separately when counting concurrent connections... Have you tried in another browser and/or watched the network tab to be sure it connects to different subdomains? – Alexander Köplinger Oct 26 '12 at 15:01
  • Yes, I used chrome network inspections tool, and 3 tabs get scripts and connections from "im", and 3 tabs from "im2". I will try to figure it out at the weekend. – Dmitry Oct 26 '12 at 15:17
  • 1
    When I use my hoster, then it works. When I use my local IIS8, then it doesn't. That means I need to setup my subdomains correctly. Everything works fine now. I feel better :) – Dmitry Oct 29 '12 at 12:40
  • @AlexanderKöplinger , I have a chat application on master page (common for all pages) and i need connection on each page then how can i have open more than 6 tabs. Any Idea would be helpful. – G.S Bhangal Sep 08 '14 at 10:13
  • @G.SBhangal , i also looking for same approach , if you would have find any solution to solve this problem , can u please share it – Sajjad Ali Khan Apr 24 '17 at 18:39
  • @SajjadAliKhan , Hi I have resolved this problem using the multiple subdomains, but keep in mind that all the subdomains should point out to the main domain and randomly load the signal R from the subdomains. – G.S Bhangal Apr 26 '17 at 07:38
1

To bypass browser limtation you can use ‛localStorage‛ to communicate between windows and to have only one window as connection owner. Other windows in this case use connection owner to receive/send messages. IWC-SignalR is an implementation of such approach.

Eugene Khudoy
  • 211
  • 2
  • 7
0

yes. You will create dynamic sub-domains for the signal R connections, because there are browser limitation for the concurrent requests [max = 8] and for different browser this concurrent limitation may vary.

For the dynamic sub-domains you need to set DNS for the sub-domains from the hosting panel, so these dynamic sub-domains point to your main domain. e.g. xyz.com is your main domain, abc1.xyz.com is your sub-domain, abc2.xyz.com is your sub-domain, abc3.xyz.com is your sub-domain, abc4.xyz.com is your sub-domain. These all sub-domains point to main domain after DNS setting and IIS setting. This same way works in Chat application. Good luck...