9

I have an API application and a web application (for simplicity on the same server -- I'll do the CORS stuff later).

  • Windows Server 2012 with IIS 8.5
  • Websockets installed through "Programs and features"
  • Firewall turned off

The api is using owin + signalr and has the proper initialization (trimmed it down to find the error):

public void Configuration(IAppBuilder app)
{
    GlobalHost.Configuration.TransportConnectTimeout = TimeSpan.FromSeconds(5);
    app.MapSignalR();
    app.UseWebApi(Startup.CreateConfiguration());
}

private static HttpConfiguration CreateConfiguration()
{
    HttpConfiguration configuration = new HttpConfiguration();
    configuration.MapHttpAttributeRoutes();
    return configuration;
}

Everything seems to work perfectly except connection to the actual websockets. Every time the client tries to establish a connection, there is a timeout and it fails over to SSE (or forever frame/long polling in IE). I increased the timeout to 25 seconds and the same symptoms are occurring.

On the client, I consistently get this error with logging turned on:

SignalR: Connecting to websocket endpoint 'ws://[myurl]'.
SignalR: Websocket opened.
SignalR: **webSockets timed out when trying to connect.**
SignalR: Closing the Websocket.
SignalR: Attempting to connect to SSE endpoint 'http://[myurl]'.
SignalR: EventSource connected.
SignalR: serverSentEvents transport selected. Initiating start request.
SignalR: The start request succeeded. Transitioning to the connected state.

I have tried following the guides provided by the signalR team and I cannot see what I am missing.

Thanks for any help!

UPDATE: I downloaded a sample and ran it as-is on the server. Same situation, so this is likely a server configuration setting that I missed along the way. I still have not found what I missed.

junkyspace
  • 365
  • 4
  • 15
  • 1
    Have you tried establishing a SignalR connection from you Windows Server machine? This might have something to do with the network. Perhaps there's a proxy or something in between the client and server that doesn't properly support WebSockets. – halter73 Aug 27 '14 at 21:33
  • Fantastic. Troubleshooting all these things and I forgot the simple rule of checking the wire. Please make this an answer so I can accept it. – junkyspace Aug 29 '14 at 12:54
  • The SignalR team is made up of politically appointed pseudo-developers. The code matters not, only the PC group affiliation.. – I Stand With Russia Apr 28 '15 at 15:38

4 Answers4

8

You need to enable WebSockets for the website in Server Manager.

http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-websocket-protocol-support

jonesy827
  • 302
  • 3
  • 11
2

Try establishing a SignalR connection from your Windows Server machine itself. This might have something to do with the network. Perhaps there's a proxy or something in between the client and server that doesn't properly support WebSockets.

halter73
  • 15,059
  • 3
  • 49
  • 60
1

If you are inside of a network with a "corporate" firewall, it can screw up the websockets handshake.

But, you can prevent this interference if you access your server over SSL. I've seen this first hand be the cause and solution multiple times for websockets problems in corporate environments.

Bon
  • 1,083
  • 12
  • 23
0

It may be something with your IIS settings. I saw these on http://www.asp.net/signalr/overview/signalr-20/getting-started-with-signalr-20/supported-platforms

-IIS must be running in integrated mode; classic mode is not supported. Message delays of up to 30 seconds may be experienced if IIS is run in classic mode using the Server-Sent Events transport.

-The hosting application must be running in full trust mode.

Also, it mentioned something about .NET 4.5 being the target framework. Hope this helped.

dkiefer
  • 501
  • 5
  • 13