Azure / azure-sdk-for-js

This repository is for active development of the Azure SDK for JavaScript (NodeJS & Browser). For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/javascript/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-js.
MIT License
2.1k stars 1.21k forks source link

[Event hub][Error]Failed to connect #15871

Closed amit12cool closed 3 years ago

amit12cool commented 3 years ago

Describe the bug Our microservice is listening on Event hub that has 32 partitions and a checkpoint store allocated. We recently experienced a error log as below:- ``"{\"level\":\"error\", \"time\":\"2021-06-10T01:17:54.268Z\",\"context\":\"EventHubService\",\"msg\":\"Error in listening on eventHub: iot-prd01-evh and partitionId : Error: Failed to connect}\"}\n",```

Our processError method looks like this:-

processError: (error, context): Promise<void> => {
    this.appLoggerService.error(
        `Error in listening on eventHub: ${context.eventHubName} and partitionId ${context.partitionId}: ${error}}`
    );
    return Promise.resolve();
}

Not sure, the exact cause of this error. Can this error be ignored or not from the application side?

To Reproduce Steps to reproduce the behavior:

  1. Run the application that listens to Event hub

Expected behavior No error should be received

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

chradek commented 3 years ago

@amit12cool Are you connecting to an Event Hub via a connection string? I noticed iot in your event hub name: are you reading events from an IoT Hub?

amit12cool commented 3 years ago

Yes, we connect via the Event hub connection string. Below is the code for initialization of consumer client:-

consumerClient = new EventHubConsumerClient(
    consumerGroup,
    connectionString,
    name,
    checkpointStore
);

yes, we read twin change events from iot hub using message routing to our Event hub. Also, we publish our own business data on the same Event hub.

chradek commented 3 years ago

Thanks for the info! I should have asked if you see this issue continuously or if it just happened once. If continuously, I wanted to check if you were using the IoT Hub connection string, or the event hubs-compatible IoT Hub connection string.

If it only happened once then it is likely due to a transient network issue and the SDK should automatically recover.

amit12cool commented 3 years ago

It seems the sdk automatically recovered as we saw this error once only. I will close this issue now.