SignalR hosted in MVC in Azure emulator has cross domain issues from JS client

I have a SignalR hub (named EventHub) hosted in an Azure web role for an MVC 4 application running in an emulator at 127.0.0.2:81. In my Application_Start application, I have:

RouteTable.Routes.MapHubs(new HubConfiguration { EnableCrossDomain = true }); 

in my JS client running through IIS on localhost: 1003, I have:

 $.connection.hub.url = 'http://127.0.0.2:81/signalr'; $.connection.hub.start().done(alert('connected')); 

My client can connect to the hub and call methods on it, but in the console I see:

 XMLHttpRequest cannot load http://127.0.0.2:81/signalr/reconnect?transport=longPolling&connectionToken…&tid=0&_=1380138173967. Origin http://localhost:1003 is not allowed by Access-Control-Allow-Origin. 

The client eventually disconnects. If I use the same client and an almost identical implementation of the hub and run it in a standalone MVC application on localhost: 62835, I don’t see errors in cross origin at all. I run this on Chrome v29. I do not have specific user headers, and I do not set jquery cors support to true.

Is there any bend that causes the azure emulator? And if so, is there any way around it?

UPDATE:

I published my web role for Azure, and cors seems to work in this environment. In addition, Chrome now uses network sockets to connect instead of trying to connect to a server hosted on the emulator using the longpolling command.

Anyway, I would like to run this through an emulator for local testing, so if anyone has any ideas on how to do this, I would be grateful.

+4
source share
1 answer

I did not receive cross-origin errors through the emulator for the local IIS Express SignalR application with the latest Azure SDK in Windows8 for the cross-origin scenario, make sure the emulator in your player is up.

0
source

All Articles