mongo-express-docker icon indicating copy to clipboard operation
mongo-express-docker copied to clipboard

Wrong check connection in connecton retry

Open rtritto opened this issue 2 years ago • 1 comments

How to reproduce

Run the image.

Actual behavior

Even if ME_CONFIG_MONGODB_URL env var is correct, in docker-entrypoint.sh the connection check fails, and the connection retry starts until the end of all tries (10 by default). After the retries, the server starts correcly.

Pattern of placeholder <CLUSTER>: cluster0-<CLUSTER_ID>.mongodb.net

Waiting for <CLUSTER>:<PORT>...
/docker-entrypoint.sh: line 15: <CLUSTER>: Name has no usable address
/docker-entrypoint.sh: line 15: /dev/tcp/<CLUSTER>/<PORT>: Invalid argument
Sun Jan  7 01:47:59 UTC 2024 retrying to connect to <CLUSTER>:<PORT> (2/10)
/docker-entrypoint.sh: line 15: <CLUSTER>: Name has no usable address
/docker-entrypoint.sh: line 15: /dev/tcp/<CLUSTER>/<PORT>: Invalid argument
Sun Jan  7 01:48:01 UTC 2024 retrying to connect to <CLUSTER>:<PORT> (3/10)
...
/docker-entrypoint.sh: line 15: <CLUSTER>: Name has no usable address
/docker-entrypoint.sh: line 15: /dev/tcp/<CLUSTER>/<PORT>: Invalid argument
Sun Jan  7 01:48:08 UTC 2024 retrying to connect to <CLUSTER>:<PORT> (10/10)
/docker-entrypoint.sh: line 15: <CLUSTER>: Name has no usable address
/docker-entrypoint.sh: line 15: /dev/tcp/<CLUSTER>/<PORT>: Invalid argument
No custom config.js found, loading config.default.js
Welcome to mongo-express 1.0.2
------------------------


Mongo Express server listening at http://0.0.0.0:8081
Server is open to allow connections from anyone (0.0.0.0)

Expected behavior

After the first connection check, the server starts without any connection retry.

Possible solution

In docker-entrypoint.sh change the code:

exec 6<>/dev/tcp/$host/$port

Documentations/guides:

  • http://tldp.org/LDP/abs/html/devref1.html
  • https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Redirections
  • https://tylersguides.com/guides/check-if-a-tcp-port-is-listening-in-bash

Issues

Related (?): #49 Similr errors but with ME_CONFIG_MONGODB_SERVER instead of ME_CONFIG_MONGODB_URL: #21 Code introduced with: #12 Code commented with: #65

rtritto avatar Jan 07 '24 02:01 rtritto

FYI @BlackthornYugen @tianon @shakaran

rtritto avatar Jan 07 '24 02:01 rtritto