SignalR won't use Websocket protocol even thou

2019-02-22 20:49发布

问题:

I'm using signalr to do some real-time events in my web application. I'm trying to force signalr to use the new websocket protocol but it won't, even if I specify it.

$.connection.hub.start({ transport: 'webSockets' })

I definitely have the web socket protocol installed and I am running Windows 8 with IIS 8.

What else do I need to do to enable web sockets support in signalr?

回答1:

Ensure that your app is using the .NET 4.5 assembly from the SignalR package. If the project is targeting 4.0, or it started that way, then nuget would have added a reference to the 4.0 SignalR assembly which doesn't support websockets. If that's the case, then just uninstall and re-install the signalr packages into your project.



回答2:

Web Sockets requires .NET 4.5.

If you try running it on Windows Server 8 in the future be sure to activate the Web Sockets feature.



回答3:

If you are already using framework 4.5 but still no luck, add an HTTPS binding to your IIS website and access the website over HTTPS.