ayeo-flex-org / pulsar-flex

Pulsar Flex is a modern Apache Pulsar client for Node.js, developed to be independent of C++.
MIT License
45 stars 8 forks source link

Is discovery server mandatory ? #87

Open yoletx opened 1 year ago

yoletx commented 1 year ago

Is your feature request related to a problem? Please describe. When creating a producer / consummer, we have to specify a discovery server.

Describe the solution you'd like I would like to directly specify the broker, and not a discovery server.

Additional context I'm quite new to pulsar, so maybe i'm completly wrong. But currently, when trying to establish a connexion, it successfuly connect to the remote server : "Authentication to discovery service established, now will lookup topic", and then find me a localhost url, that can't work because everything is on the remote server.

{"level":"INFO","timestamp":"2022-10-06T09:04:03.388Z","logger":"pulsar-flex","message":"Creating client connection for producer to topic: persistent://public/default/MY_TOPIC"}
{"level":"INFO","timestamp":"2022-10-06T09:04:03.389Z","logger":"pulsar-flex","message":"Starting to lookup topic persistent://public/default/MY_TOPIC on __________________________________:6650"}        
{"level":"INFO","timestamp":"2022-10-06T09:04:03.417Z","logger":"pulsar-flex","message":"Connected successfully __________________________________:6650, now sending connect command."}
{"level":"INFO","timestamp":"2022-10-06T09:04:03.444Z","logger":"pulsar-flex","message":"Authentication to discovery service established, now will lookup topic"}
{"level":"INFO","timestamp":"2022-10-06T09:04:03.467Z","logger":"pulsar-flex","message":"Closing connection to discovery connection"}
{"level":"INFO","timestamp":"2022-10-06T09:04:03.469Z","logger":"pulsar-flex","message":"Lookup succeeded, owner is localhost:6650"}
Error: connect ECONNREFUSED 127.0.0.1:6650
galrose commented 1 year ago

The discovery server is a pulsar broker. I'm not sure why it searches for localhost I would check some cluster configurations :)

yoletx commented 1 year ago

Some more explanation. Our pulsar server is in standalone. We don't have a discovery service running. I made some tests yesterday and found a workaround, it looks ok, but seem a little strange. On pulsar server conf, the parameter advertisedAddress was no set. If not set it equal to localhost. So i set this to the external hostname (same that i use when passing discoveryServers parameter in new Producer) and it's ok. Conclusion is : Maybe pulsar-flex should be able to directly contact broker server without "searching for advertisedAddress parameter on the server". Why ? Because JAVA library allow this (our server was used by external JAVA producer without problems and without having to set advertisedAddress in the conf.)

galrose commented 1 year ago

That's interesting, we also have a standalone for the tests here so you could see if there are any differences there. It makes sense though, I'll take a look at it. Thanks for the info :)