SignalR 2.2.0 WebSocket error connecting to hub

15,520

This may be due to the fact that your web server doesn't support WebSockets (IIS 7.5, for instance. It may also be due to the fact that you are using a "proxy" server like ARR and it just cannot "route" WebSocket requests.

The first thing I would try to do is to disable WebSockets on SignalR, just as a debug tool. Here's how: SignalR - How do I disable WebSockets

If your problem persists, it's a general SignalR problem but at least you will have a more specific error. If the problem stops, now you know it is a server issue.

Share:
15,520
Bardicer
Author by

Bardicer

I am a web applications developer with five years of experience. I graduated from Arkansas Tech with a degree in Information Systems and a minor in Management and Marketing. Technologies I have used include: WCF Services C# .Net 3.0 - 4.5.2 PHP MySQL SQL Server ReSharper ASP.Net Razor MVC Classic ASP pages Silverlight jQuery KnockoutJS

Updated on June 09, 2022

Comments

  • Bardicer
    Bardicer almost 2 years

    I have an ASP.Net MVC application that I have added SignalR to. After following the "Getting Started" tutorial (with modifications of course since it's going in my application) I got it working on localhost. However once it's in the production environment, I get the following error:

    WebSocket connection to 'ws://xxxxx/signalr/connect?transport=webSockets&clientProtocol=1.5&connectionToken=xxxxx' failed: Connection closed before receiving a handshake response.

    I can access /signalr/hubs (I get a js file). Any ideas as to why this would happen?

  • Bardicer
    Bardicer almost 9 years
    Ok, so that got rid of my error. Now I just have to figure out why it doesn't seem to be making the actual call. Thanks!
  • Andre Pena
    Andre Pena almost 9 years
    I'm glad you figured that out. What web server are you using? Are you using a cluster?
  • Bardicer
    Bardicer almost 9 years
    We're using IIS 7 - that's all I know. I don't have access to the server itself, so I'm having to have someone else make changes/uploads for me. Not sure if it's a cluster or not, but my guess is that it's not.
  • Bardicer
    Bardicer almost 9 years
    With the longpolling transport set, I'm basically timing out in production on the "Content Download" section of the call. Looking in chrome devtools - stalled 0.191ms, request sent 0.080ms, waiting (ttfb) 42.949ms, content download 1.9 min. Running locally it takes less than a second for everything to happen and also have results (I know what it should be returning)
  • Frank M
    Frank M almost 7 years
    I know you have marked the question as answered but just in case anyone else comes across this it looks like your issue is that you are using IIS7. The supported platforms specifically state that you need IIS8 to support Web Sockets. Most likely what is happening is that SignalR is attempting to use Web Sockets but automatically downgrades the connection.
  • mikeschuld
    mikeschuld over 6 years
    Checking the ARR server as well was the solution for me. Both of our other servers had the WebSockets support installed but not our load balancer.