dotnet / aspire

Tools, templates, and packages to accelerate building observable, production-ready apps
https://learn.microsoft.com/dotnet/aspire
MIT License
3.92k stars 479 forks source link

[WebToolsE2E][Aspire] After adding Aspire.Confluent.Kafka component and related codes, there are some messages "localhost:xxxxx/bootstrap: Disconnected while requesting ApiVersion" in CMD when running the aspire project. #5971

Open Rita003 opened 1 month ago

Rita003 commented 1 month ago

INSTALL STEPS

  1. Clean machine: Win11 x64 23h2 ENU
  2. Install SDK 9.0.100-rc.2.24474.11

    • Apply feed for SDK 9.0 RC2
  3. Install Aspire 9.0.0-preview.4.24475.9

    • Apply the dotnet8 feed for Aspire 9.0

REPRO STEPS

  1. Open CMD, create an Aspire Starter App using following commands:
    dotnet new aspire-starter -o AspireStarterApp
    cd AspireStarterApp
  2. Add the Aspire.Confluent.Kafka component to your AspireStarterApp.Web app:
    cd AspireStarterApp.Web
    dotnet add package Aspire.Confluent.Kafka --version 9.0.0-preview.4.24475.9
  3. In the Program.cs file of the AspireStarterApp.Web project, type following codes: builder.AddKafkaProducer<string, string>("messaging");
  4. Open appsettings.json of AspireStarterApp.AppHost project, add ConnectionStrings configuration section:
    {
    "ConnectionStrings": {
    "myConnection": "broker:9092"
    }
    }
  5. Add the Aspire.Hosting.Kafka component to your AspireStarterApp.AppHost app:
    cd ..
    cd AspireStarterApp.AppHost
    dotnet add package Aspire.Hosting.Kafka --version 9.0.0-preview.4.24475.9
  6. Open Program.cs of AspireStarterApp.AppHost project, add following codes:
    
    var messaging = builder.AddKafka("messaging");

var myService = builder.AddProject() .WithReference(messaging);

7. Run the project in CMD, and open URL in the browser.
`dotnet run`

**ACTUAL**
After the messaging container state is running, there are some messages in CMD.
![Screenshot 2024-09-27 111635](https://github.com/user-attachments/assets/f6a3f4e4-a729-4122-9357-ae183392cca0)

**Error Log:**

%6|1727406956.153|FAIL|rdkafka#producer-1| [thrd:localhost:59716/bootstrap]: localhost:59716/bootstrap: Disconnected while requesting ApiVersion: might be caused by incorrect security.protocol configuration (connecting to a SSL listener?) or broker version is < 0.10 (see api.version.request) (after 5001ms in state APIVERSION_QUERY) %3|1727406956.153|ERROR|rdkafka#producer-1| [thrd:localhost:59716/bootstrap]: 1/1 brokers are down %3|1727406956.153|ERROR|rdkafka#producer-1| [thrd:app]: rdkafka#producer-1: localhost:59716/bootstrap: Disconnected while requesting ApiVersion: might be caused by incorrect security.protocol configuration (connecting to a SSL listener?) or broker version is < 0.10 (see api.version.request) (after 5001ms in state APIVERSION_QUERY)

davidfowl commented 1 month ago

This is a duplicate of https://github.com/dotnet/aspire/issues/5939

cc @mitchdenny

Rita003 commented 3 weeks ago

This issue doesn't repro after installing the latest released SDK 8.0.403 + Aspire 8.2.2. This issue also repro after installing the latest SDK 9.0GA + Aspire 9.0.0

davidfowl commented 3 weeks ago

Same as https://github.com/dotnet/aspire/issues/6516 but for hosting.

davidfowl commented 3 weeks ago

@g7ed6e any ideas?

g7ed6e commented 3 weeks ago

This occurs only at consumer side and is not related to aspire.. I used to see these logs in a différent context and I think this is a bug in librdkafka when the consumer is connecting to the broker because the error logs quickly stop being emitted and the consumer start receiving messages. The librdkakfa logs are forwarded to Confluent.Kakfa which are forwarded to aspire. I will see if I can find an issue we can link to in librdkakfa and Confluent.Kafka.

jonathan-mcewan commented 2 days ago

@g7ed6e could it have anything with the health checks attempting to create a producer with kafka before it's fully started?

https://github.com/dotnet/aspire/blob/b81e1c6a67db9bec2298d5e9831b088855cd9951/src/Aspire.Hosting.Kafka/KafkaBuilderExtensions.cs#L67

While it's a rdkafka error, if it's the health check then can we have it reported as such?