question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EventHubProducerClient with custom_endpoint_address fails with: ErrorCodes.UnknownError: Connection in an unexpected error state.

See original GitHub issue
  • Package Name: azure.eventhub
  • Package Version: azure_eventhub-5.10.1.dist-info
  • Operating System: Linux or Windows
  • Python Version: Python 3.10.7

Describe the bug

Running the following code sample:

from azure.eventhub import EventData, EventHubProducerClient, TransportType
from azure.identity import EnvironmentCredential

credential = EnvironmentCredential()

producer = EventHubProducerClient(
    fully_qualified_namespace="<evh namespace>", 
    eventhub_name="<evh name>",
    credential=credential,
    logging_enable=True,  # To enable network tracing log, set logging_enable to True.
    retry_total=0,  # Retry up to 3 times to re-do failed operations.
    custom_endpoint_address = "sb://<endpoint address>:5671")

with producer:
    event_data_batch = producer.create_batch()
    event_data_batch.add(EventData('Message inside EventBatchData'))
    producer.send_batch(event_data_batch)

print('Finished sending.')

Fails with the following message:

ConnectionClose('ErrorCodes.UnknownError: Connection in an unexpected error state.')
Traceback (most recent call last):
  File "C:\Users\azureadmin\AppData\Local\Programs\Python\Python310\lib\site-packages\azure\eventhub\_client_base.py", line 567, in _do_retryable_operation
    return operation()
  File "C:\Users\azureadmin\AppData\Local\Programs\Python\Python310\lib\site-packages\azure\eventhub\_client_base.py", line 526, in _open
    while not self._handler.client_ready():
  File "C:\Users\azureadmin\AppData\Local\Programs\Python\Python310\lib\site-packages\uamqp\client.py", line 385, in client_ready
    self._connection.work()
  File "C:\Users\azureadmin\AppData\Local\Programs\Python\Python310\lib\site-packages\uamqp\connection.py", line 252, in work
    raise self._error
uamqp.errors.ConnectionClose: ErrorCodes.UnknownError: Connection in an unexpected error state.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\azureadmin\Desktop\pysample\send.py", line 15, in <module>
    event_data_batch = producer.create_batch()
  File "C:\Users\azureadmin\AppData\Local\Programs\Python\Python310\lib\site-packages\azure\eventhub\_producer_client.py", line 714, in create_batch
    self._get_max_message_size()
  File "C:\Users\azureadmin\AppData\Local\Programs\Python\Python310\lib\site-packages\azure\eventhub\_producer_client.py", line 321, in _get_max_message_size
    )._open_with_retry()
  File "C:\Users\azureadmin\AppData\Local\Programs\Python\Python310\lib\site-packages\azure\eventhub\_producer.py", line 152, in _open_with_retry
    return self._do_retryable_operation(self._open, operation_need_param=False)
  File "C:\Users\azureadmin\AppData\Local\Programs\Python\Python310\lib\site-packages\azure\eventhub\_client_base.py", line 583, in _do_retryable_operation
    raise last_exception
azure.eventhub.exceptions.ConnectionLostError: Connection in an unexpected error state.
ErrorCodes.UnknownError: Connection in an unexpected error state.

Same thing happens if the custom endpoint is changed to https://<endpoint address>:443

Expected behavior Messages should flow to the Event Hub using a custom endpoint address for both AmqpWebSockets and AmqpTcp.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
l0lawrencecommented, Sep 28, 2022

Yes, we can definitely look into adding support for it over TCP. I have made an issue here: #26513 to track the progress.

1reaction
cmendiblecommented, Sep 28, 2022

Will AmqpTcp be supported as other SDK’s such as .NET do?

Read more comments on GitHub >

github_iconTop Results From Across the Web

[EventHub] ErrorCodes.UnknownError: Connection in an ...
The goal is to check whether new azure sdk package work with other clouds or not. Error Description: When running the test test_send.py:: ......
Read more >
IoT hub AMQP connection closed error - Microsoft Q&A
ConnectionClose('ErrorCodes.UnknownError: Connection in an unexpected error state.') Traceback (most recent call last): File "c:\Users\B00760928 ...
Read more >
Azure event Hub connection is closed error - Stack Overflow
I once tried that if I call the close() method in EventHubProducerClient (by refer to sample code in https://learn.microsoft.com/en-us/azure/ ...
Read more >
Azure Event hub input error in Microsoft Cloud Services add on
Solved: Hi All, we are getting below error while adding app account ... REST Error [400]: Bad Request -- Account authentication failed.
Read more >
Azure Event Hubs client library for Python - NET
This lets you process and analyze the massive amounts of data produced by your connected devices and applications. Once Event Hubs has collected...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found