0

I am working on a MVC application using asp.net which contains 4 portion which need to be updated in real-time.

I started this with having different hub classes in signalR. But it turns out that signalR is making 4 different connection one for each portion to support this which is increasing the load over server and sometime it is not at all possible to have more than 2 connection.

Curious to know if there exist any way by which I can handle using only one connection.

In short,

One application -> 4 signalR portion need to be handle by 1 signalR connection.

cauchy
  • 1,123
  • 1
  • 9
  • 19
  • Just have one hub with a bunch of different functions, then how you choose to implement the calls in JavaScript is up to you. – Ashley Medway Jan 15 '16 at 11:57
  • @AshleyMedway you are fairly correct I am planning to implement this solution only . But this document http://www.asp.net/signalr/overview/guide-to-the-api/hubs-api-guide-server#signalrurl says multiple Hub classes shared the connection but groups will be separate under multiple hubs section. – cauchy Jan 15 '16 at 12:02
  • sounds interesting I will look into this. – Ashley Medway Jan 15 '16 at 12:03
  • share with me also if you find anything interesting. – cauchy Jan 15 '16 at 12:06

1 Answers1

0

One page can connect to multiple hubs without issue. It will be over one connection, so nothing to worry about. It's dead easy with the generated proxy (see http://www.asp.net/signalr/overview/guide-to-the-api/hubs-api-guide-javascript-client#genproxy).

You will get a different connectionId for each hub, but that shouldn't be a problem.

thab
  • 666
  • 1
  • 6
  • 14
  • using proxy for different hub classes is not a problem. My question is more about using one single shared connection over multiple hub classes. – cauchy Jan 15 '16 at 15:13
  • Great @thab can you give some example of that, where you have multiple hub classes and using one single connection. – cauchy Jan 15 '16 at 15:25
  • It's all done for you. See: http://stackoverflow.com/questions/11764360/multiple-signalr-connections-hubs-on-your-website#22151160 – thab Jan 15 '16 at 15:30
  • I guess that only applies to SignalR v2.x+. Could that be a difference @cauchy? – thab Jan 15 '16 at 15:36
  • Yeah this feature is added in SignalR v2.x+. – cauchy Jan 18 '16 at 06:26
  • So... what version of SignalR are you using @cauchy? If v2+ then it'll be fine, if not then I'm not that sure, and it looks like it won't work. – thab Jan 18 '16 at 12:38
  • I am using version 2.2. Let me check what I am doing wrong then I will get back to you. – cauchy Jan 19 '16 at 04:48