Skip to content
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

Deployment Issue connecting to redis one-click-app #1941

Open
jplana01 opened this issue Nov 17, 2023 · 7 comments
Open

Deployment Issue connecting to redis one-click-app #1941

jplana01 opened this issue Nov 17, 2023 · 7 comments
Labels
deployment-issue not-caprover-specific Not related to CapRover. Related to Docker, nginx, other apps, and etc

Comments

@jplana01
Copy link

Hey guys, just started using Caprover, I'm trying to deploy my app, however when I tried to connect to a Redis one-click-app I created in the same domain I get

Error: getaddrinfo ENOTFOUND srv-captain--my-redis
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26) {
  errno: -3008,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'srv-captain--my-redis-app'
}

When I tried using the container IP Adress as my host variable I get this

Error: connect ETIMEDOUT
    at TLSSocket.<anonymous> (/app/node_modules/ioredis/built/Redis.js:170:41)
    at Object.onceWrapper (events.js:421:28)
    at TLSSocket.emit (events.js:315:20)
    at TLSSocket.Socket._onTimeout (net.js:483:8)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7) {
  errorno: 'ETIMEDOUT',
  code: 'ETIMEDOUT',
  syscall: 'connect'
}

My config is

const bullConfig: BullConfig = {
  connection: Env.get('BULL_CONNECTION', 'local'),

  connections: {
    local: {
      host: Env.get('BULL_REDIS_HOST', 'localhost'),
      port: Env.get('BULL_REDIS_PORT'),
      username: Env.get('BULL_REDIS_USERNAME'),
      password: Env.get('BULL_REDIS_PASSWORD'),
      tls: {
        cert: fs.readFileSync("./cert/ca.crt"),
        rejectUnauthorized: false,
      },
      connectTimeout: 60000,
    },
  }

Any ideas why? How can I troubleshoot it?

@githubsaturn
Copy link
Collaborator

What's the output of docker service ls and docker ps ?

Can you try shelling into your app container and just run curl -v srv-captain--my-redis

@jplana01
Copy link
Author

jplana01 commented Nov 19, 2023

First thanks for the fast answer, I'm having a great experience with Caprover and this just made it even better.

docker service ls returns

ID             NAME                          MODE         REPLICAS   IMAGE                              PORTS
3bh16ew7z0h8   captain-captain               replicated   1/1        caprover/caprover:1.11.1           
so82cje2gv5n   captain-certbot               replicated   1/1        caprover/certbot-sleeping:v1.6.0   
ncjs62p2v5qb   captain-nginx                 replicated   1/1        nginx:1.24                         
764908ph1yb9   srv-captain--agroplus-db-pg   replicated   1/1        postgres:14.5                      
qr5c20zyrujv   srv-captain--agroplus-site    replicated   1/1        img-captain-agroplus-site:0        
xbfh72ctpnw3   srv-captain--agrouplus-api    replicated   1/1        img-captain-agrouplus-api:0        
lwczz8l9ry7j   srv-captain--my-redis-app     replicated   1/1        img-captain-my-redis-app:1         *:6380->6379/tcp, *:6380->6379/udp

docker ps

CONTAINER ID   IMAGE                              COMMAND                  CREATED      STATUS      PORTS                                                                      NAMES
fb83bd383060   caprover/certbot-sleeping:v1.6.0   "/bin/sh -c 'sleep 9…"   2 days ago   Up 2 days   80/tcp, 443/tcp                                                            captain-certbot.1.v4hcpuzmypwq91n4e0m9cz9v0
ee012d5ab236   nginx:1.24                         "/docker-entrypoint.…"   2 days ago   Up 2 days   0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp   captain-nginx.1.1372593q4o8lc2djcvk7u7sv1
9784290c153a   caprover/caprover:1.11.1           "docker-entrypoint.s…"   2 days ago   Up 2 days   0.0.0.0:3000->3000/tcp, :::3000->3000/tcp                                  captain-captain.1.5xdey581x7le2w57z3gbabtmh
408afff764a4   img-captain-my-redis-app:1         "docker-entrypoint.s…"   2 days ago   Up 2 days   6379/tcp                                                                   srv-captain--my-redis-app.1.oziam27icjd79sb4yghzxnnoq
a0739e0cf3f3   img-captain-agrouplus-api:0        "/docker-entrypoint.…"   2 days ago   Up 2 days   80/tcp                                                                     srv-captain--agrouplus-api.1.jhp67ndgb9aw4kn6759m90m6v
a94a5f1138cd   caprover/netdata:v1.34.1           "/run.sh"                4 days ago   Up 4 days   19999/tcp                                                                  captain-netdata-container
9877f5e3a5e0   img-captain-agroplus-site:0        "/docker-entrypoint.…"   5 days ago   Up 5 days   80/tcp                                                                     srv-captain--agroplus-site.1.m891xlrk0ty4682mbx5j17rem
88ef97714bd3   postgres:14.5                      "docker-entrypoint.s…"   5 days ago   Up 5 days   5432/tcp                                                                   srv-captain--agroplus-db-pg.1.tr83bz5pnj7chdwilceec3y2q

curl -v srv-captain--my-redis-app.1.oziam27icjd79sb4yghzxnnoq

*   Trying 10.0.1.65:80...
* connect to 10.0.1.65 port 80 failed: Connection refused
* Failed to connect to srv-captain--my-redis-app.1.oziam27icjd79sb4yghzxnnoq port 80: Connection refused
* Closing connection`

Ps: In my first post I've used srv-captian--my-redis-app as Caprover says "Your app is internally available as srv-captain--my-redis-app to other Captain apps.", I've deleted the app part by accident when pasting in the start of the error message

@githubsaturn
Copy link
Collaborator

Thanks! Now try doing curl -v srv-captain--my-redis-app
Do not include the ".1.oziam27icjd79sb4yghzxnnoq" suffix

Just to confirm, you're running this from inside agrouplus-api or agrouplus-site` ?

@jplana01
Copy link
Author

The output now is
`* Trying 10.0.1.8:80...

  • connect to 10.0.1.8 port 80 failed: Connection refused
  • Failed to connect to srv-captain--my-redis-app port 80: Connection refused
  • Closing connection 0
    curl: (7) Failed to connect to srv-captain--my-redis-app port 80: Connection refused`

Yes, inside agrouplus-api

@githubsaturn
Copy link
Collaborator

Okay, that's great! So based on the output, it looks like the hostname srv-captain--my-redis-app is indeed being mapped to an ip address (10.0.1.8) inside the container.

There are many reasons why from inside your code it's not resolved properly. But whatever it is, the reason lies within your application. Next step for you should be to try running bash command from your code to see you're getting the IP address resolved. If that works, I suggest post your question to StackOverflow. It might have something to do with the library / framework you're using.

@githubsaturn githubsaturn added the not-caprover-specific Not related to CapRover. Related to Docker, nginx, other apps, and etc label Nov 19, 2023
@jplana01
Copy link
Author

Alright thanks a lot, I've been trying to fix that, do you think the ETIMEDOUT error could be caused by that as well?

@githubsaturn
Copy link
Collaborator

Very likely... something on your system is preventing containers to talk to each other...

It could be a custom firewall, custom OS, etc etc...

Use digital ocean and see if the issue still exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployment-issue not-caprover-specific Not related to CapRover. Related to Docker, nginx, other apps, and etc
Projects
None yet
Development

No branches or pull requests

2 participants