Click here to Skip to main content
16,022,069 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a project that I am trying to get connected to a rabbit mq broker that I have set up on fly.io with a node.js API, but I cannot figure out how to do this.

What I have tried:

I tried various ways of re-writing the url for the amqp connection, but none of these worked. Here is my environment variable:

#----Service Dependency Variables----
RABIT_MQ_URL=amqp://rabbit-mq-fly-dep.fly.dev:5672
#----Service Dependency Variables----


I also tried this format:

<pre>#----Service Dependency Variables----
RABIT_MQ_URL=amqp://USERNAME:PASSWORD@rabbit-mq-fly-dep.fly.dev:5672/VHOST_NAME
#----Service Dependency Variables----


however, the error that I got in my node.js app is still the same:

ERR {
  success: false,
  message: Error: getaddrinfo ENOTFOUND rabbit-mq-fly-dep.fly.dev
      at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:120:26) {
    errno: -3008,
    code: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'rabbit-mq-fly-dep.fly.dev'
  }
}


I have been looking online at other resources, but I can't find anything that could help me. The docs didn't seem to be much help either unless you want to connect to a local host which is easy:

<pre>#----Service Dependency Variables----
RABIT_MQ_URL=amqp://locahost
#----Service Dependency Variables----


This works every time if I run a rabbit MQ instance locally, of course xD

Any help on how to get this working would be much appreciated. Thanks!
Posted

1 solution

You could always try to connect via the IP address. In your dashboard, use fly ips list to get the valid IP addresses you can use. Also, if you require SSL/TLS, use amqps rather than amqp.
 
Share this answer
 
Comments
Baraiboapex 26-Sep-24 12:37pm    
@Pete O'Hanlon Nope, I'm affraid that this didn't work. If it helps any, here is the docker file and toml file for the rabbit mq instance:

docker file:
FROM rabbitmq:3-management-alpine
COPY ./prod.conf /etc/rabbitmq/rabbitmq.conf
RUN rabbitmq-plugins enable rabbitmq_management


fly toml:
# fly.toml app configuration file generated for rabbit-mq-fly-dep on 2024-09-25T14:16:38-04:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'rabbit-mq-fly-dep'
primary_region = 'mia'

[build]

[[services]]
  protocol = "tcp"
  internal_port = 5672

  [[services.tcp_checks]]
    interval = "15s"
    timeout = "1m0s"
    grace_period = "1s"

  [[services.ports]]
    port = 5673
    handlers = ["tls"]

[[services]]
  protocol = "tcp"
  internal_port = 15672

  [[services.ports]]
    port = 15672
    handlers = ["tls", "http"]

  [[services.tcp_checks]]
    interval = "15s"
    timeout = "1m0s"
    grace_period = "1s"
Baraiboapex 26-Sep-24 12:38pm    
Oh, and the .config file if that helps too:
listeners.tcp.default=5672
default_user=admin
default_pass=admin
management.tcp.ip=::
Baraiboapex 26-Sep-24 12:42pm    
I do apologize if this comment is too long for this forum xD. Please let me know and I can send you this information via email or something.
Pete O'Hanlon 27-Sep-24 7:18am    
Have you created your fly proxy yet? If not, you won't be able to see this outside the cluster:
fly proxy -a rabbit-mq-fly-dep 15672
Baraiboapex 27-Sep-24 10:35am    
Oooooh xD duh! Let me try that!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900