Azure EvenHub:由于异常而无法启动连接:[Errno 9] 错误的文件描述符

问题描述 投票:0回答:1

我有一个脚本应该将数据发送到 Azure 事件中心。但是,当我运行脚本时,我收到下面的错误消息,但我找不到任何参考。几个月前运行了相同的脚本。谢谢你。

    Traceback (most recent call last):
      File "test.py", line 82, in <module>
        getAirThings()
      File "test.py", line 76, in getAirThings
        event_data_batch = producer.create_batch()
                                        ^^^^^^^^^^^^^^^^^^^^^^^
      File ".venv/lib/python3.11/site-packages/azure/eventhub/_producer_client.py", line 740, in create_batch
        self._get_max_message_size()
      File ".venv/lib/python3.11/site-packages/azure/eventhub/_producer_client.py", line 336, in _get_max_message_size
        )._open_with_retry()
         ^^^^^^^^^^^^^^^^^^
      File ".venv/lib/python3.11/site-packages/azure/eventhub/_producer.py", line 155, in _open_with_retry
        return self._do_retryable_operation(self._open, operation_need_param=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File ".venv/lib/python3.11/site-packages/azure/eventhub/_client_base.py", line 608, in _do_retryable_operation
        raise last_exception from None

    azure.eventhub.exceptions.ConnectError: Failed to initiate the connection due to exception: [Errno 9] Bad file descriptor
     Error condition: ErrorCondition.SocketError
     Error Description: Failed to initiate the connection due to exception: [Errno 9] Bad file descriptor

azure azure-eventhub
1个回答
0
投票

我能够用 Amqp 解决:

from azure.eventhub import TransportType

producer = EventHubProducerClient.from_connection_string(
    conn_str = connectionString, 
    eventhub_name = eventHubName, 
    transport_type = TransportType.AmqpOverWebsocket
)
© www.soinside.com 2019 - 2024. All rights reserved.