[英]Connecting to Event Hub
In my code below I am attempting to create a producer client that i can use to send events to a Event Hub.在我下面的代码中,我试图创建一个生产者客户端,我可以用它来将事件发送到事件中心。 I am getting a System.PlatformNotSupportedException: 'The WebSocket protocol is not supported on this platform.
我收到System.PlatformNotSupportedException: '此平台不支持 WebSocket 协议。 error Any guidance on how i can resolve this would be much appreciated.
错误 任何有关我如何解决此问题的指导将不胜感激。 FYI my platform is Windows 7, although this program is intended to run on a windows 2008 server or later.
仅供参考,我的平台是 Windows 7,尽管该程序旨在在 Windows 2008 服务器或更高版本上运行。
var producerOptions = new EventHubProducerClientOptions
{
ConnectionOptions = new EventHubConnectionOptions
{
TransportType = EventHubsTransportType.AmqpWebSockets,
},
RetryOptions = new EventHubsRetryOptions
{
MaximumRetries = 5,
TryTimeout = TimeSpan.FromMinutes(1)
}
};
var producer = new EventHubProducerClient(connectionString, eventHubName, producerOptions);
//here is where the error occurs. //这里是错误发生的地方。 which is inside a try - catch block
这是在 try-catch 块内
var eventBatch = await producer.CreateBatchAsync();
...... ......
The Event Hubs client library relies on the underlying framework for its transport communication.事件中心客户端库依赖于其传输通信的基础框架。 In this case, it sounds as if you're using the full .NET Framework on Windows 7, where web sockets is not supported.
在这种情况下,听起来好像您在不支持 Web 套接字的 Windows 7 上使用完整的 .NET Framework。
So long as your aren't using a UWP application, changing the target framework to .NET Core and using the netstandard2.0
target from the client library may work.只要您不使用 UWP 应用程序,将目标框架更改为 .NET Core 并使用客户端库中的
netstandard2.0
目标就可以工作。 (see: this PR ) (见:这个 PR )
More detail can be found in the accepted answer for this question , which also contains some advice for third party packages that may work as a polyfill.可以在此问题的已接受答案中找到更多详细信息,其中还包含对可能用作 polyfill 的第三方软件包的一些建议。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.