【问题标题】:Error in create_authenticator when listening to Azure EventHub from organization network从组织网络收听 Azure EventHub 时 create_authenticator 出错
【发布时间】:2021-05-21 18:19:02
【问题描述】:

我正在尝试使用以下代码从 Azure 事件中心读取数据。当我在组织网络之外时,此代码可以正常工作,但使用 Pulse VPN 或在组织 LAN 网络中,它会失败并出现身份验证错误。 我也尝试过提供代理,但没有运气。阅读有关打开端口 5672 和 5671 的解决方案。我不确定在哪里以及如何执行此操作,可能在 Windows 防火墙中?如果是这样,那么这也不起作用。

已安装:Python 3.9 和 azure.eventhub==5.4.0

conn_str="Endpoint=sb://myeventhub.servicebus.windows.net/;EntityPath=xxxxxx;SharedAccessKeyName=listen;SharedAccessKey=xxxxxxxxxx"
client = EventHubConsumerClient.from_connection_string(conn_str=conn_str, consumer_group=consumer_group, http_proxy=HTTP_PROXY, https_proxy=HTTPS_PROXY)
partition_ids = client.get_partition_ids()

错误:

Traceback (most recent call last):
  File "C:\Python\lib\site-packages\uamqp\authentication\cbs_auth.py", line 69, in create_authenticator
    self._cbs_auth = c_uamqp.CBSTokenAuth(
  File ".\src/cbs.pyx", line 72, in uamqp.c_uamqp.CBSTokenAuth.__cinit__
ValueError: Unable to open CBS link.

【问题讨论】:

    标签: python azure azure-eventhub


    【解决方案1】:

    这表示客户端无法连接到事件中心命名空间。如果您的组织允许不受限制地使用端口 80 和 443,您可能需要在创建客户端时考虑使用 Web 套接字传输。这个sample 演示了通过配置;第 43 行是设置传输类型的示例,您需要将类型更改为 TransportType.AmqpOverWebSocket

    【讨论】:

    • 我尝试了以下但看到了同样的错误。在 netstat 中,我看到端口 0.0.0.0:80 正在监听,所以这意味着端口 80 是开放的。 client = EventHubConsumerClient.from_connection_string( conn_str=conn_str, consumer_group=consumer_group, logging_enable=False, http_proxy=HTTP_PROXY, transport_type=TransportType.AmqpOverWebsocket )
    • @user15994794,80 端口不用于连接——TransportType.AmqpOverWebSocket 使用端口 443,而 TransportType.Amqp 使用端口 5671。请问您的环境是否允许使用端口 443?跨度>
    • 端口 443 是不允许的。但是,问题已通过使用不同的代理地址得到解决。
    猜你喜欢
    • 2016-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-28
    • 2017-03-28
    • 1970-01-01
    • 2021-04-13
    相关资源
    最近更新 更多