WhatsApp / WhatsApp-Business-API-Setup-Scripts

The scripts related to setting up WhatsApp business API
MIT License
410 stars 433 forks source link

web container stuck in Running state even it didn't connect to mysql #29

Closed Goodsmileduck closed 4 years ago

Goodsmileduck commented 4 years ago
Apr 29, 2020 @ 19:27:21.020 MySQL is up. Starting /opt/whatsapp/bin/launch_within_docker.sh
Apr 29, 2020 @ 19:27:21.110 Failed to create web db or store db settings to database.yml file.
Apr 29, 2020 @ 19:27:21.110 An exception occured in driver: SQLSTATE[08004] [1040] Too many connections
Apr 29, 2020 @ 19:27:21.110 #0 /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php(2): Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException('An exception oc...', Object(Doctrine\DBAL\Driver\PDOException))
Apr 29, 2020 @ 19:27:21.110 #1 /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php(2): Doctrine\DBAL\DBALException::driverException(Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Object(Doctrine\DBAL\Driver\PDOException))
Apr 29, 2020 @ 19:27:21.110 #2 /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(2): Doctrine\DBAL\Driver\PDOMySql\Driver->connect(Array, 'root', 'password...', Array)
Apr 29, 2020 @ 19:27:21.110 #3 /var/www/html/src/WhatsApp/Database/DBConnection.php(2): Doctrine\DBAL\Connection->connect()
Apr 29, 2020 @ 19:27:21.110 #4 /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(2): WhatsApp\Database\DBConnection->connect()
Apr 29, 2020 @ 19:27:21.110 #5 /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(2): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
Apr 29, 2020 @ 19:27:21.110 #6 /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(2): Doctrine\DBAL\Connection->detectDatabasePlatform()
Apr 29, 2020 @ 19:27:21.110 #7 /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php(2): Doctrine\DBAL\Connection->getDatabasePlatform()
Apr 29, 2020 @ 19:27:21.110 #8 /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php(2): Doctrine\DBAL\Schema\AbstractSchemaManager->__construct(Object(WhatsApp\Database\DBConnection))
Apr 29, 2020 @ 19:27:21.110 #9 /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(2): Doctrine\DBAL\Driver\AbstractMySQLDriver->getSchemaManager(Object(WhatsApp\Database\DBConnection))
Apr 29, 2020 @ 19:27:21.110 #10 /var/www/html/src/WhatsApp/Database/DBUtil.php(2): Doctrine\DBAL\Connection->getSchemaManager()
Apr 29, 2020 @ 19:27:21.110 #11 /var/www/html/src/WhatsApp/Database/DBUtil.php(2): WhatsApp\Database\DBUtil->createDatabase(Object(WhatsApp\Database\DBConnection), 'waweb')
Apr 29, 2020 @ 19:27:21.110 #12 /var/www/html/src/WhatsApp/Scripts/CreateWebDB.php(2): WhatsApp\Database\DBUtil->createDBConnection(Array)
Apr 29, 2020 @ 19:27:21.110 #13 {main}
Apr 29, 2020 @ 19:27:21.120 Added SSL configuration
Apr 29, 2020 @ 19:27:21.121 Creating self-signed certificate for server: localhost
Apr 29, 2020 @ 19:27:21.141 Generating RSA private key, 2048 bit long modulus
Apr 29, 2020 @ 19:27:21.158 ............+++
Apr 29, 2020 @ 19:27:21.318 ............................................................................................+++
Apr 29, 2020 @ 19:27:21.318 e is 65537 (0x10001)
Apr 29, 2020 @ 19:27:21.318 Created root CA key
Apr 29, 2020 @ 19:27:21.321 You are about to be asked to enter information that will be incorporated
Apr 29, 2020 @ 19:27:21.321 into your certificate request.
Apr 29, 2020 @ 19:27:21.321 There are quite a few fields but you can leave some blank
Apr 29, 2020 @ 19:27:21.321 For some fields there will be a default value,
Apr 29, 2020 @ 19:27:21.321 If you enter '.', the field will be left blank.
Apr 29, 2020 @ 19:27:21.321 -----
Apr 29, 2020 @ 19:27:21.321 What you are about to enter is what is called a Distinguished Name or a DN.
Apr 29, 2020 @ 19:27:21.323 
Apr 29, 2020 @ 19:27:21.323 Created root CA (autogen) certificate
Apr 29, 2020 @ 19:27:21.326 Country Name (2 letter code) [AU]:State or Province Name (full name) [Some-State]:Locality Name (eg, city) []:Organization Name (eg, company) [Internet Widgits Pty Ltd]:Organizational Unit Name (eg, section) []:Common Name (e.g. server FQDN or YOUR name) []:Email Address []:Generating RSA private key, 2048 bit long modulus
Apr 29, 2020 @ 19:27:21.364 .................................+++
Apr 29, 2020 @ 19:27:21.376 ..........+++
Apr 29, 2020 @ 19:27:21.376 e is 65537 (0x10001)
Apr 29, 2020 @ 19:27:21.376 Created device key for localhost
Apr 29, 2020 @ 19:27:21.379 You are about to be asked to enter information that will be incorporated
Apr 29, 2020 @ 19:27:21.379 into your certificate request.
Apr 29, 2020 @ 19:27:21.379 What you are about to enter is what is called a Distinguished Name or a DN.
Apr 29, 2020 @ 19:27:21.379 There are quite a few fields but you can leave some blank
Apr 29, 2020 @ 19:27:21.379 For some fields there will be a default value,
Apr 29, 2020 @ 19:27:21.379 If you enter '.', the field will be left blank.
Apr 29, 2020 @ 19:27:21.379 -----
Apr 29, 2020 @ 19:27:21.379 Country Name (2 letter code) [AU]:State or Province Name (full name) [Some-State]:Locality Name (eg, city) []:Organization Name (eg, company) [Internet Widgits Pty Ltd]:Organizational Unit Name (eg, section) []:Common Name (e.g. server FQDN or YOUR name) []:Email Address []:
Apr 29, 2020 @ 19:27:21.379 Please enter the following 'extra' attributes
Apr 29, 2020 @ 19:27:21.379 to be sent with your certificate request
Apr 29, 2020 @ 19:27:21.381 
Apr 29, 2020 @ 19:27:21.381 Created device certificate signing request
Apr 29, 2020 @ 19:27:21.383 A challenge password []:An optional company name []:Signature ok
Apr 29, 2020 @ 19:27:21.383 subject=/CN=localhost
Apr 29, 2020 @ 19:27:21.384 Getting CA Private Key
Apr 29, 2020 @ 19:27:21.385 Signed device certificate
Apr 29, 2020 @ 19:27:21.388 Deleted root CA (autogen) key
Apr 29, 2020 @ 19:27:21.388 Provisioning certificates
Apr 29, 2020 @ 19:27:21.408 PHP Fatal error:  Uncaught PDOException: SQLSTATE[08004] [1040] Too many connections in /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:2
Apr 29, 2020 @ 19:27:21.408 Stack trace:
Apr 29, 2020 @ 19:27:21.408 #0 /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(2): PDO->__construct('mysql:host=wa-v...', 'root', 'password...', Array)
Apr 29, 2020 @ 19:27:21.408 #1 /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php(2): Doctrine\DBAL\Driver\PDOConnection->__construct('mysql:host=wa-v...', 'root', 'password...', Array)
Apr 29, 2020 @ 19:27:21.408 #2 /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(2): Doctrine\DBAL\Driver\PDOMySql\Driver->connect(Array, 'root', 'password...', Array)
Apr 29, 2020 @ 19:27:21.408 #3 /var/www/html/src/WhatsApp/Database/DBConnection.php(2): Doctrine\DBAL\Connection->connect()
Apr 29, 2020 @ 19:27:21.408 #4 /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(2): WhatsApp\Database\DBConnection->connect()
Apr 29, 2020 @ 19:27:21.408 #5 /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(2): Doctrine\DBAL\Connection->getDatabasePlatformVersion( in /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php on line 2
Apr 29, 2020 @ 19:27:21.417 SSL Hardened
Apr 29, 2020 @ 19:27:21.417 SSL enabled
Apr 29, 2020 @ 19:27:21.417 Provisioned certificates successfully
Apr 29, 2020 @ 19:27:21.418 Cleaned up staging area
Apr 29, 2020 @ 19:27:21.519  * Starting web server lighttpd
Apr 29, 2020 @ 19:27:21.535 2020-04-29 10:27:21: (network.c.537) SSL: BIO_read_filename('/var/lib/whatsapp/www.cert') failed
Apr 29, 2020 @ 19:27:21.536    ...fail!
Apr 29, 2020 @ 19:27:21.536 Web server started
Apr 29, 2020 @ 19:27:21.537 tail: cannot open '/var/log/lighttpd/error.log' for reading: No such file or directory
Apr 29, 2020 @ 19:27:21.537 tail: cannot open '/var/log/whatsapp/web.log' for reading: No such file or directory
Apr 29, 2020 @ 19:27:21.537 Starting web monitor loop ...
Apr 29, 2020 @ 19:27:21.543 Setting up watches.
Apr 29, 2020 @ 19:27:21.543 Watches established.

after that it stays running, and no logs we using v2.27.8

jhow2892 commented 4 years ago

Hello, this happened to me when the data in db.env was incorrect, and why are you using version v2.28.7 if the official WhatsApp documentation is at 2.27.12?

mengyiyuan commented 4 years ago

Hello, this happened to me when the data in db.env was incorrect, and why are you using version v2.28.7 if the official WhatsApp documentation is at 2.27.12?

Are you referring to v2.27.8? The version is only an example and you should refer to the changelog in the documentation for the latest version number. :)

mengyiyuan commented 4 years ago

@Goodsmileduck Can you verify if it is the same case as #15 ?

Goodsmileduck commented 4 years ago

sorry, it's 2.27.8 @mengyiyuan yes, it's almost the same thing when web container can't connect to mysql. I will try to reproduce it once time again to get more logs from containers.

BTW from docs, it's not clear how to use WA_API_KEY Deployed v2.27.11 version to dev env. I set for web container WA_API_KEY=1938thwuerfiw3h05thgqiefo87w46yh, but how I can use it now? request with --header 'Authorization: Bearer 1938thwuerfiw3h05thgqiefo87w46yh' return me:

{"meta":{"version":"v2.27.11","api_status":"stable"},"errors":[{"code":1005,"title":"Access denied","details":"Missing or invalid authentication credentials"}]}
Goodsmileduck commented 4 years ago

ok, looks like I found. I should be

--header 'Authorization: Apikey 1938thwuerfiw3h05thgqiefo87w46yh'
mengyiyuan commented 4 years ago

Sorry for the late reply. Glad that you found the solution, I will close this issue now.

Rajamohanreddyai commented 3 years ago

Hello ,

I was created the whole setup at that time I got the same error, but at the next second I was fixed the same. Mainly because of 2 reasons you may get the URL not found errors.

Containers are not up (db, coreapp, webapp). You might be calling the wrong URL. Please check the below link if do you want any clarity. https://youtu.be/hYO32rQQ9Pc