问题
I am working on an application using the Microsoft.Azure.Devices.Client NuGet package. Everything is running great on Windows 10, but when testing on a Win7 machine I get this aggregate exception.
System.PlatformNotSupportedException: The WebSocket protocol is not supported on this platform.
Searching around I have found a couple threads saying that this is not supported on Windows 7 and there were some "Microsoft's working on it" type comments.
https://github.com/5andr0/PogoLocationFeeder/issues/229
I have not much for updates or solutions since 2016.
A little more searching lead me down the path of the Microsoft Web Platform Installer https://www.microsoft.com/web/downloads/platform.aspx
We tried to install "IIS 10.0 Express" and "Microsoft Azure PowerShell" with still no luck.
We are in the process of installing all Web Platforms that I have on my W10 machine on the W7 as well... most of which seemed to have 1-to-1 support.
Can anyone comment on if this is done or planned for W7?
Or do I really need to look in another direction before I try to make something impossible work?
Maybe a missing package in my installer for W7 besides the Web Service Installs?
Thanks in advance for any input here!!!
回答1:
Everything you did after "A little more searching" is on the wrong path. Please stop doing that.
Short answer is, you are trying to make something impossible work, as Microsoft itself is reluctant to support WebSockets on Windows Vista and 7 (out of mainstream support a long time ago). Try to use other alternative ways, and stop wasting your time.
Long answer is,
- Microsoft's current assumption is always WebSockets requires Windows 8 and above. That's because the restriction lies in
http.sys
and HTTP API, which is an OS component. - Microsoft does have the technologies to support WebSockets on Windows Vista and 7 for .NET apps without OS level changes, by reusing their managed implementation of WebSockets support for macOS and Linux. They do not yet finish all the work, https://github.com/dotnet/corefx/issues/9503
As the GitHub issue status (up-for-grabs) reveals, if you like you can continue the work and help yourself. I won't say it is impossible, but compared to moving to a feasible alternatives, it is no simpler.
Of course, if you are ambitious and capable of tough things, you definitely should step up and resolve it, not only for yourself, but for all similar developers like you.
Good luck.
[Updated on Mar 27, 2018]
https://github.com/dotnet/corefx/pull/26429
Microsoft finally enables the managed implementation everywhere (except UWP). So if your apps target .NET Core 2.1 and above, it should be able to run WebSockets on Windows Vista/7. The story about .NET Framework apps is unknown yet.
回答2:
I had the same problem and solved it using the following nuget package:
System.Net.WebSockets.Client.Managed
https://www.nuget.org/packages/System.Net.WebSockets.Client.Managed/
github source: https://github.com/PingmanTools/System.Net.WebSockets.Client.Managed
Creates a ClientWebSocket that works for this platform. Uses System.Net.WebSockets.ClientWebSocket if supported or System.Net.WebSockets.Managed.ClientWebSocket if not.
来源:https://stackoverflow.com/questions/48011763/windows-7-websocket-platformnotsupportedexception