How to configure IIS 7.5 for SSE (events sent by the server) and SignalR

I tested an ASP.NET MVC application to run SignalR and correctly handled MIME text/event-stream with a serverSentEvents connection using Visual Studio 2012, IIS Express (Microsoft-IIS / 8.0) and Chrome.

Now, when I deploy the working environment (IIS 7.5, .NET Framework 4.5, Windows Server 2008R2), I noticed that SignalR always returns to the LongPolling transport, because signalr/connect?transport=serverSentEvents etc disconnected.

Is there a way to configure Microsoft-IIS / 7.5 for ServerSentEvents? Or is this only possible on 8.0 +?

When I try to directly access the URL 'http://my.webapp.com/MyHub/signalr/connect?transport=serverSentEvents&connectionId=624849a4-45c6-458b-b6d0-f7cb023ab226&connectionData=%5B%7B%22name%22%3A%22myHub%22%7D%5D&tid=2' I get a file that contains what looks like an SSE data packet:

 data: initialized id: 14476 data: {"MessageId":"14476","Messages":[],"Disconnect":false,"TimedOut":false,"TransportData":{}} 

so I don’t know why the timeout hits on demand.

+7
source share
2 answers

It turns out that in my case there was no specific configuration - SignalR returning to longPolling depended on the fact that my server is clearly a proxy.

To check this, I suggest trying to connect to the hub server on the server using localhost as the web address - in my case the transport is correctly configured as serverSentEvents (when using Chrome) or foreverFrame (when using IE)

Credit for dfowler user for head units (more details here )

+7
source

What can happen is that the server compresses the dynamic content generated before sending it to the client. Add this to your web.config to fix

  <location path="signalr"> <system.webServer> <urlCompression doDynamicCompression="false"/> </system.webServer> </location> 
+1
source

All Articles