mongo-express / mongo-express-docker

a dockerized mongo-express for viewing mongoDB in the browser
MIT License
198 stars 93 forks source link

Wrong check connection in connecton retry #115

Open rtritto opened 6 months ago

rtritto commented 6 months ago

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 \: cluster0-.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:

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 commented 6 months ago

FYI @BlackthornYugen @tianon @shakaran