fsprojects / pulsar-client-dotnet

Apache Pulsar native client for .NET (C#/F#/VB)
MIT License
304 stars 48 forks source link

use Multi Hosts Service Url feature #279

Open wyq985910398 opened 2 weeks ago

wyq985910398 commented 2 weeks ago

When I use the multi hosts service url feature, such as broker1 and broker2, if broker1 is stopped when the program is started, the program will not start. Can this be optimized? Java can start.

Lanayx commented 2 weeks ago

Can you please provide code example, so it will be clear what multi-address feature you mean?

wyq985910398 commented 2 weeks ago

` const string serviceUrl = "pulsar://192.168.0.96:6501,192.168.0.96:6500"; const string subscriptionName = "my-subscription"; var topicName = "my-topic-003"; IConsumer<byte[]> consumer = null; PularClient client = await new PulsarClientBuilder() .ServiceUrl(serviceUrl)
.BuildAsync();

IProducer<byte[]> producer = null; try { producer =await client.NewProducer() .Topic(topicName) .CreateAsync(); Console.WriteLine("temp"); } catch (Exception ex) { Console.WriteLine("get Exception"); }` The address contains two brokers. One of them is in a stopped state. The feature is Multi Hosts Service Url.

Lanayx commented 2 weeks ago

@wyq985910398 I can't reproduce the issue locally. I've modified service url like that

let pulsarAddress = "pulsar://127.0.0.1:9950;127.0.0.1:6650" // first address doesn't exist

and basic test works after several reconnect retries