I'm using GAE Flex environment to serve a Laravel application. I have setup everything and the app is working. I have also setup MemoryStore Redis server and tried to connect to the server from GAE Flex Laravel app but when I try to deploy my app I get Predis\Connection\ConnectionException: Connection timed out [tcp://10.70.**.**:6379]
error.
I have setup MemoryStore Redis server and get the IP address of the server and put it into my app.yaml file as follows. My app is in the us-east1
region and MemoryStore Redis region is also us-east1
.
I also followed Google's official documentation: https://cloud.google.com/memorystore/docs/redis/connect-redis-instance-flex
This is working for a pure PHP app but not working for Laravel app. It is not required but I also created a VPC and tried with it too but it did not work neither.
I also asked it to Google Cloud Support but they could not help neither and since it is Laravel related they suggested me to ask it to the Stackoverflow community.
runtime: php
env: flex
manual_scaling:
instances: 1
runtime_config:
document_root: public
front_controller_file: index.php
whitelist_functions: proc_open
enable_stackdriver_integration: true
env_variables:
MYSQL_USER: dbusername
MYSQL_PASSWORD: ******
MYSQL_DSN: mysql:dbname=mydbname;unix_socket=/cloudsql/project-name:us-east1:sql-server-name
APP_URL: https://www.myapp.com
APP_KEY: ******
APP_ENV: local
APP_DEBUG: true
APP_LOG: stackdriver
APP_LOG_LEVEL: debug
LOG_CHANNEL: stackdriver
DB_CONNECTION: mysql
DB_HOST: 127.0.0.1
DB_PORT: 3306
DB_DATABASE: mydbname
DB_USERNAME: dbusername
DB_PASSWORD: ******
DB_SOCKET: /cloudsql/project-name:us-east1:sql-server-name
BROADCAST_DRIVER: log
CACHE_DRIVER: redis
QUEUE_CONNECTION: database
SESSION_DRIVER: cookie
SESSION_LIFETIME: 120
REDIS_HOST: "10.70.**.**"
REDIS_PORT: "6379"
FILESYSTEM_DRIVER: local
beta_settings:
cloud_sql_instances: project-name:us-east1:sql-server-name
network:
name: default
I expect to connect to the MemoryStore Redis without any errors. But I still get this error:
Step #2: Predis\Connection\ConnectionException : Connection timed out [tcp://10.70.**.**:6379]
Step #2:
Step #2: at /app/vendor/predis/predis/src/Connection/AbstractConnection.php:155
Step #2: 151| */
Step #2: 152| protected function onConnectionError($message, $code = null)
Step #2: 153| {
Step #2: 154| CommunicationException::handle(
Step #2: > 155| new ConnectionException($this, static::createExceptionMessage($message), $code)
Step #2: 156| );
Step #2: 157| }
Step #2: 158|
Step #2: 159| /**
Step #2:
Step #2: Exception trace:
Step #2:
Step #2: 1 Predis\Connection\AbstractConnection::onConnectionError("Connection timed out")
Step #2: /app/vendor/predis/predis/src/Connection/StreamConnection.php:128
Step #2:
Step #2: 2 Predis\Connection\StreamConnection::createStreamSocket(Object(Predis\Connection\Parameters), "tcp://10.70.**.**:6379")
Step #2: /app/vendor/predis/predis/src/Connection/StreamConnection.php:178
I've found the solution to this issue. There were two commands to prepare caches before using the app. I've removed these commands from post-install-cmd
in the composer.json
file. If anyone needs more detail I can help them. Just comment here.
Before:
"post-install-cmd": [
"chmod -R 777 bootstrap\/cache",
"chmod -R 777 storage",
"php artisan cache:clear",
"php artisan optimize"
]
After:
"post-install-cmd": [
"chmod -R 777 bootstrap\/cache",
"chmod -R 777 storage",
]