I have a single script that is supposed to send data to Azure Event Hub. However when I run the script I get the error message below for which I couldn't find any reference. The same script was running a couple of months ago. Thank you.
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
I was able to solve this with Amqp. Here's the context of the problem. The script:
Call an API
Convert the returned data to JSON
Create the EventHub producer with the
connectionStringandEventHubparameters. This is the part of the code where I added thetransport_typeparameter to solve the issue.Create a batch
Add the API data output to the batch
Send the event data to the Azure EventHub