SignalR: Error during WebSocket handshake: Unexpected response code: 400

后端 未结 5 1986
旧巷少年郎
旧巷少年郎 2020-12-31 04:22

I have just started working with SignalR. I have implemented real-time data reflection on my site using signalr. I was getting \"Error during Web-Socket handshake: Unexpecte

相关标签:
5条回答
  • 2020-12-31 05:01

    use this tag in your web.config file :

    <httpRuntime maxRequestLength="40960" targetFramework="4.5" requestValidationMode="2.0" />
    

    under <system.web> tag. Describe your target framework.Error will be disappear

    0 讨论(0)
  • 2020-12-31 05:04

    If the problem are the proxies that exists in the path from client to server, there is nothing you can do but complain to your provider (both client and server).

    How HTML5 Web Sockets Interact With Proxy Servers

    By using a secure connection, you ensure that no proxy is going to mess with your connection.

    0 讨论(0)
  • 2020-12-31 05:05

    If you're behind Nginx, add these three lines (the ones starting with proxy_):

    server {       
        listen       443; # Or 80 or whatever
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        ...
    }
    

    HTTPS/HTTP is not the issue. WSS will be automatically used on HTTPS pages, and WS used on HTTP, without any manual setting.

    0 讨论(0)
  • 2020-12-31 05:11

    I was having same issue in .Net Core Web API with Angular 8 front end. The issue in my case was the Websocket protocol was not installed on server. Installed it from Server manager -> Add Roles and Features and it worked

    0 讨论(0)
  • 2020-12-31 05:14

    This 400 error can also happen if you are running on multiple servers behind a load balancer. Inspect the body of the 400 response (ex., using Fiddler) and see if you find this: The ConnectionId is in the incorrect format. If so, then your problem may be that you are not using the same machine key on each application server.

    See this answer for details on the solution: https://stackoverflow.com/a/43479474/979202

    0 讨论(0)
提交回复
热议问题