SignalR: Error during WebSocket handshake: Unexpec

2019-02-09 02:48发布

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: Unexpected response code: 400" error on console with when trying to connect with web-socket.

Application is developed with Asp.net MVC - signalR 2.0.3 and hosted On Windows server 2012 - IIS 8

I found one solution from this link

It says that We need website to point to HTTPS (and avail SSL) then http to work with web-socket. And my Issue resolved too. My doubt is - cant we solve this issue without using HTTPS ? As each website might not require to be hosted on HTTPS (which requires SSL).

3条回答
趁早两清
2楼-- · 2019-02-09 03:05

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.

查看更多
Viruses.
3楼-- · 2019-02-09 03: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

查看更多
孤傲高冷的网名
4楼-- · 2019-02-09 03:20

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

查看更多
登录 后发表回答