我正在使用GAE Flex环境来服务Laravel应用程序。我已经设置了所有内容,并且该应用程序正在运行。我还设置了MemoryStore Redis服务器,并尝试从GAE Flex Laravel应用连接到该服务器,但是当我尝试部署我的应用时,出现Predis\Connection\ConnectionException: Connection timed out [tcp://10.70.**.**:6379]
错误。
我已经设置了MemoryStore Redis服务器并获取服务器的IP地址,并将其放入我的app.yaml文件中,如下所示。我的应用程序位于us-east1
区域中,MemoryStore Redis区域也位于us-east1
。
我还遵循了Google的官方文档:https://cloud.google.com/memorystore/docs/redis/connect-redis-instance-flex
这适用于纯PHP应用程序,但不适用于Laravel应用程序。它不是必需的,但我也创建了一个VPC并尝试使用它,但是它也不起作用。
我也向Google Cloud Support提出了要求,但他们也无济于事,由于与Laravel有关,他们建议我向Stackoverflow社区提出要求。
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
我希望没有任何错误地连接到MemoryStore Redis。但我仍然收到此错误:
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
答案 0 :(得分:0)
我找到了解决此问题的方法。在使用该应用程序之前,有两个命令可以准备缓存。我已经从post-install-cmd
文件的composer.json
中删除了这些命令。如果有人需要更多细节,我可以帮助他们。在这里发表评论。
之前:
"post-install-cmd": [
"chmod -R 777 bootstrap\/cache",
"chmod -R 777 storage",
"php artisan cache:clear",
"php artisan optimize"
]
之后:
"post-install-cmd": [
"chmod -R 777 bootstrap\/cache",
"chmod -R 777 storage",
]