Azure / azure-event-hubs-go

Golang client library for Azure Event Hubs https://azure.microsoft.com/services/event-hubs
MIT License
90 stars 69 forks source link

eventhub.NewHubWithNamespaceNameAndEnvironment blocks for more than 3 mins #180

Open abhirockzz opened 4 years ago

abhirockzz commented 4 years ago

Expected Behavior

Behavior of eventhub.NewHubWithNamespaceNameAndEnvironment should have sane defaults when invalid arguments (event hubs namespace and/or event hub name etc.) are passed i.e. timeout/fail in a reasonable amount of time

Or, it should allow the caller to enforce timeout by allowing it pass in a context.Context

Actual Behavior

I tried two scenarios:

  1. did not pass in valid event hubs namespace and/or event hub name (code was expecting it from env vars which I had missed and hence blank "" was passed in)
  2. did not pass in AAD env vars (AZURE_CLIENT_ID etc.) or SAS env vars

In both cases, I got the below error, but the app was stuck for ~3.5 mins

failed to create EH client neither Azure Active Directory nor SAS token provider could be built - AAD error
: failed to refersh token: &{{{  0 0 0  } 0x1668640 {{  <nil>    false  } {  <nil>    false  } {http  <nil> 169.254.169.254 /me
tadata/identity/oauth2/token  false api-version=2018-02-01&resource=https%3A%2F%2Feventhubs.azure.net%2F } {  <nil>    false  }
}  https://eventhubs.azure.net/ true 300000000000} 0xc0000c01a0 0xc00009d020 <nil> [] 5}, SAS error: unable to build SAS token 
provider because (EVENTHUB_KEY_NAME and EVENTHUB_KEY_VALUE) were empty, and EVENTHUB_CONNECTION_STRING was empty

Environment

catalinaperalta commented 3 years ago

Hi! Thanks for reaching out.

I haven't been able to reproduce this error. I created a simple example that only calls eventhub.NewHubWithNamespaceNameAndEnvironment and first did not set any environment variables and the error response returned was almost immediate. Then I set the vars you mentioned in your first scenario and the result was the same. I received the error response again almost immediately. Do you have code that could reproduce this problem so that I could test it out?