giandonatoinverso / PHP-Dynamic-Qr-code

PHP Dynamic Qr code is a script that allows the generation and saving of dynamic and static QR codes
MIT License
268 stars 76 forks source link

docker: Cannot connect #72

Open Aurel004 opened 11 months ago

Aurel004 commented 11 months ago

Hi,

I installed the latest docker version. I can enter the login page but when I succefully login (using default qrcode/changeme) I get this error :

Fatal error: Uncaught mysqli_sql_exception: Connection refused in /var/www/html/lib/MysqliDb/MysqliDb.php:323 Stack trace: #0 [internal function]: mysqli->__construct('php-dynamic-qrc...', 'qrcode', Object(SensitiveParameterValue), 'qrcode', 3306, NULL) #1 /var/www/html/lib/MysqliDb/MysqliDb.php(323): ReflectionClass->newInstanceArgs(Array) #2 /var/www/html/lib/MysqliDb/MysqliDb.php(415): MysqliDb->connect('default') #3 /var/www/html/lib/MysqliDb/MysqliDb.php(1988): MysqliDb->mysqli() #4 /var/www/html/lib/MysqliDb/MysqliDb.php(1594): MysqliDb->_prepareQuery() #5 /var/www/html/lib/MysqliDb/MysqliDb.php(738): MysqliDb->_buildQuery(1) #6 /var/www/html/lib/MysqliDb/MysqliDb.php(764): MysqliDb->get('users', 1, '*') #7 /var/www/html/authenticate.php(17): MysqliDb->getOne('users') #8 {main} thrown in /var/www/html/lib/MysqliDb/MysqliDb.php on line 323

giandonatoinverso commented 11 months ago

Have you used docker compose? Have you made sure that both stack containers are running?

Aurel004 commented 11 months ago

Yes I’ve used docker-compose and default values (just changed volume locations) and yes both containers are running

giandonatoinverso commented 11 months ago

What credentials are you using to log in?

Aurel004 commented 11 months ago

As default : qrcode/changeme

giandonatoinverso commented 11 months ago

these are the database credentials. In the documentation you will find the default credentials, that is:

superadmin superadmin

Aurel004 commented 11 months ago

Oh sorry, it's now working

I have an other issue, I don't know if you want me to open a new topic but Dynamic QRCode generates a "http://0.0.0.0:80" link when it should be "https://mydomain.com:customport"

In docker-compose.yml I've edited the port to `ports:

giandonatoinverso commented 11 months ago

it's a problem that has already been solved, try creating new qr codes and clearing the cache

Aurel004 commented 11 months ago

Tried to start from scratch (deleted images, volumes and containers), now when I'm trying to logging in with superadmin/superadmin I get this error :

Fatal error: Uncaught mysqli_sql_exception: Connection refused in /var/www/html/lib/MysqliDb/MysqliDb.php:323 Stack trace: #0 [internal function]: mysqli->__construct('php-dynamic-qrc...', 'qrcode', Object(SensitiveParameterValue), 'qrcode', 3306, NULL) #1 /var/www/html/lib/MysqliDb/MysqliDb.php(323): ReflectionClass->newInstanceArgs(Array) #2 /var/www/html/lib/MysqliDb/MysqliDb.php(415): MysqliDb->connect('default') #3 /var/www/html/lib/MysqliDb/MysqliDb.php(1988): MysqliDb->mysqli() #4 /var/www/html/lib/MysqliDb/MysqliDb.php(1594): MysqliDb->_prepareQuery() #5 /var/www/html/lib/MysqliDb/MysqliDb.php(738): MysqliDb->_buildQuery(1) #6 /var/www/html/lib/MysqliDb/MysqliDb.php(764): MysqliDb->get('users', 1, '*') #7 /var/www/html/authenticate.php(17): MysqliDb->getOne('users') #8 {main} thrown in /var/www/html/lib/MysqliDb/MysqliDb.php on line 323

Aurel004 commented 11 months ago

Okay it started working well out of nowhere, restarted container and tada, hope it won't crash

Seems like an issue when both containers starts at "the same time". It work when I restart the classic container after the db container started for a few seconds

giandonatoinverso commented 11 months ago

Hi, this problem has already happened to me with other containers. Maybe it could be solved with a sleep timer between one container and another but I've never looked into it. If you want you can contribute to the project by finding a solution to this problem.