本文介绍了.NET Core是否支持Web套接字?引发" System.Net.WebSockets.WebSocketException异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用.NET 核心2.1 .

I have written console application using .NET Core 2.1.

此应用程序的责任是:连接到天蓝色 IoT中心并发送数据.

The responsibility of this application is: Connect to the Azure IoT hub and send data.

我仍然低于例外情况

注意:

Note:

  • 我在
  • 使用网络套接字
  • 在Windows 10中正常工作
  • I am running my code on Windows 7 compact OS device.
  • Using web sockets
  • Works fine in Windows 10

这是我的裸露引用

   using Microsoft.Azure.Devices.Client;
   using Microsoft.Azure.Devices.Shared;

这就是我创建连接的方式.

This is how I create connection.

   string deviceConnectionString = "*******";
  _Client = DeviceClient.CreateFromConnectionString(deviceConnectionString, TransportType.Mqtt_WebSocket_Only);

网络套接字在Windows 7上将无法使用.参考:使用 Windows 7上的WebSocket

web sockets will not work on windows 7. Reference: Using WebSocket on Windows 7

因此,我正在使用.NET Core 2.1获得Web套接字支持,如此处所述 https://github.com/dotnet/corefx/issues/20191

So I am using .NET Core 2.1 to get web socket support, as mentioned here https://github.com/dotnet/corefx/issues/20191

我仍然遇到相同的错误!

Still I get the same error!

以下是什么意思?


非常感谢Deepak


Many Thanks Deepak

推荐答案

您是否正在遵循教程或示例代码?您检查过该存储库了吗?

Were you following a tutorial or sample code? Have you checked this repository?

https://github.com/Azure-Samples/azure-iot-samples-csharp

关于

Alberto Vega

Alberto Vega


这篇关于.NET Core是否支持Web套接字?引发" System.Net.WebSockets.WebSocketException异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 03:22
查看更多