我正在使用 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
.
我还关注了谷歌的官方文档: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