-
Notifications
You must be signed in to change notification settings - Fork 41
Unable to create producer when connected to localhost and rabbit uses a hostname #296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I am not sure whether this is the same issue here is my environment: Deployed to windows wsl kind. AddressResolver = new AddressResolver(new DnsEndPoint("localhost", 30552)),
Endpoints = new List<EndPoint> { new DnsEndPoint("localhost", 30552) }, If I don't provide |
you need add advertised_host localhost for rmq
|
This is related in a slightly different setup. The |
After resolving this issue, you won't even need to advertise the host/port 🙂 |
Related to #296 It is common to have a local instance of RabbitMQ running locally, either via a local rabbit (e.g. installed from source), or inside a container (e.g. Docker or local Kubernetes). In both cases, our client may not work without providing an address resolver, or without changing the advertised host/port in rabbit via an env variable. Specifically, our clients won't work if the client can't resolve the hostname of the local machine. For exampe, a laptop may have a hostname mylaptop.some-company.com. Rabbit won't be impacted as long as it works in a single-node configuration. However, the client smart features to locate the stream leaders and replicas will get "confused" because it can't resolve the hostname. This commit changes the smart layer, so that it won't try to locate the stream replicas if the client is connected to localhost. Instead, it will force the producer/consumer connections to be localhost, and it will assume that stream replicas/leader are in localhost. This is true for single-node rabbits in local development environments. The smart feature to locate leader/replicas remains unchanged for non-local connections. Signed-off-by: Aitor Perez Cedres <[email protected]>
Related to #296 It is common to have a local instance of RabbitMQ running locally, either via a local rabbit (e.g. installed from source), or inside a container (e.g. Docker or local Kubernetes). In both cases, our client may not work without providing an address resolver, or without changing the advertised host/port in rabbit via an env variable. Specifically, our clients won't work if the client can't resolve the hostname of the local machine. For exampe, a laptop may have a hostname mylaptop.some-company.com. Rabbit won't be impacted as long as it works in a single-node configuration. However, the client smart features to locate the stream leaders and replicas will get "confused" because it can't resolve the hostname. This commit changes the smart layer, so that it won't try to locate the stream replicas if the client is connected to localhost. Instead, it will force the producer/consumer connections to be localhost, and it will assume that stream replicas/leader are in localhost. This is true for single-node rabbits in local development environments. The smart feature to locate leader/replicas remains unchanged for non-local connections. Signed-off-by: Aitor Perez Cedres <[email protected]>
* Improve local development experience Related to #296 It is common to have a local instance of RabbitMQ running locally, either via a local rabbit (e.g. installed from source), or inside a container (e.g. Docker or local Kubernetes). In both cases, our client may not work without providing an address resolver, or without changing the advertised host/port in rabbit via an env variable. Specifically, our clients won't work if the client can't resolve the hostname of the local machine. For exampe, a laptop may have a hostname mylaptop.some-company.com. Rabbit won't be impacted as long as it works in a single-node configuration. However, the client smart features to locate the stream leaders and replicas will get "confused" because it can't resolve the hostname. This commit changes the smart layer, so that it won't try to locate the stream replicas if the client is connected to localhost. Instead, it will force the producer/consumer connections to be localhost, and it will assume that stream replicas/leader are in localhost. This is true for single-node rabbits in local development environments. The smart feature to locate leader/replicas remains unchanged for non-local connections. --- Signed-off-by: Aitor Perez Cedres <[email protected]>
Describe the bug
From this conversation: spring-projects/spring-amqp#2522
When RabbitMQ is running in a environment where rabbit node name is not resolvable by the clients, and the client connects locally via the loopback, the client library fails to create a producer and retries infinitely.
This kind of setups are common for local development environments, where rabbit may resolve its node name as
foobar
, and the client connects vialocalhost
. One example is running rabbit locally, and another, running rabbit in a container.Reproduction steps
StreamSystem
that connects tolocalhost
and default port5552
Producer.Create()
Observe that the client does not create the producer connection, and it retries infinitely.
Expected behavior
The client library connects via localhost, or gives up connecting.
Additional context
Related rabbitmq/rabbitmq-server#9424
The issue can be workarounded using an address resolver, or changing the advertised host/port to always be
localhost
and the default stream port. However, there's a fair point made in the Spring Boot discussion: spring-projects/spring-amqp#2522 (comment). In summary, if there's no load balancer involved (address resolved was created for LB setups), and there's no rabbit cluster, then thelocalhost
and default loopback user configuration should work.This may arguably be an improvement, rather than a bug.
The text was updated successfully, but these errors were encountered: