Last post Apr 26, 2017 12:19 AM by zstay
Apr 20, 2017 09:19 AM|zstay|LINK
I'm currently working on SignalR and i found out that there is connection limitation of browser (can only open up to 6 tabs).
So, i've looked up for a lot of suggestion for the workaround and eventually i decided to go for multiple subdomain methods.
After i've implemented the subdomain method (creating a lot of subdomain binding to the same ip address example: bla.msg.com,bla1.msg.com,bla2.msg.com and etc), it did overcome the limitation problem however, having the URL changing(having messy URL such
as bla5.msg.com) is not something i want. So, i looked through the documentation of SignalR and i found out that i might be able to establish connection to the hub using cross domain method, which means that i dont have to
redirect my URL(having messy URL) but stay with same URL but having different connection to my subdomain hub (bla1.msg.com/signalr/hubs , bla2.msg.com/signalr/hubs and etc.)
I checked on the chrome socket monitor and the connection of bla1.msg.com is there but it is not active while the connection of bla.msg.com is active.
I've tried the things that mentioned on the documentation including the following code (included in startup.cs):
app.Map("/signalr", map =>
// Setup the CORS middleware to run before SignalR.
// By default this will allow all origins. You can
// configure the set of origins and/or http verbs by
// providing a cors options with a different policy.
var hubConfiguration = new HubConfiguration
// You can enable JSONP by uncommenting line below.
// JSONP requests are insecure but some older browsers (and some
// versions of IE) require JSONP to work cross domain
EnableJSONP = true
// Run the SignalR pipeline. We're not using MapSignalR
// since this branch already runs under the "/signalr"
So, it seems that the cross domain is not working the way i expected it to be (which is having active web sockets on bla1.msg.com in this case). Am i on the wrong track or is there any idea why the cross domain is not working? Thank you !
Apr 21, 2017 09:36 AM|Eric Du|LINK
About the apply a cross-domain connection in SignalR 1.X , please refer to the following code:
var hubConfiguration = new HubConfiguration();
hubConfiguration.EnableCrossDomain = true;
About apply a cross-domain connection in SignalR 2.X, please use Microsoft.Owin.Cors.
for more details, please refer to this document:
How to establish a cross-domain connection:
Apr 26, 2017 12:19 AM|zstay|LINK
I'm currently using SignalR 2.X and i've tried using the Microsoft.Owin.Cors but it doesnt seem to work.It seems that it would not allow me to specify the url by this statement:
$.connection.hub.url = "/signalr"
Is there any other methods of your recommendation?