简体   繁体   English

连接到事件中心

[英]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.

相关问题 可以通过浏览器和 websockets 连接到 azure 事件中心吗? - Possible to connect to an azure event hub through a browser and websockets? 从浏览器端连接到Azure IoT / Event集线器 - Connect to Azure IoT/Event hub from browser side 使用 python 在 Azure 事件中心收集 Websocket 流数据 - Collect Websocket streaming data in Azure Event Hub using python 如何持续从证券交易所等网站获取数据并使用 python 将其发送到 azure 事件中心? - How to continuously fetch data from websites like Stock exchange and send it to azure event hub using python? html5 / js websocket:在连接之后设置事件处理程序? - html5 / js websocket: setting event handlers *after* connecting? WebSocket,即使在触发 onopen 事件后,仍处于 CONNECTING 状态 - WebSocket, even after firing onopen event, still in CONNECTING state SignalR 集线器连接错误与 Flutter - SignalR Hub Connection Error With Flutter WebSocket 未连接 - WebSocket not connecting 每个SignalR集线器是否都有专用的网络套接字 - Does each SignalR hub has a dedicated websocket 通知/集线器上的 Traefik 2 和 bitwarden rs 协议 ws - Traefik 2 and bitwarden rs protocol ws on notifications/hub
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM