如何在GCP Flex环境上设置websocket? [英] How do i setup websocket on GCP Flex environment?

查看:107
本文介绍了如何在GCP Flex环境上设置websocket?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用laravel 6,并且我想在Google Cloud Flex应用引擎平台上使用主管部署基于laravel的websocket服务器.

I am using laravel 6 and I want to deploy laravel based websocket server using supervisor on google cloud Flex app engine platform.

我正在使用此程序包:beyondcode/laravel-websockets

I am using this package: beyondcode/laravel-websockets

我已经设置了所有内容,并且在本地计算机上一切正常!在GCP上部署它的确切步骤是什么?

I have setup everything and everything is working fine on local machine! What is the exact procedure to follow to deploy it on GCP?

我的extra-supervisord.conf

My additional-supervisord.conf

[program:websockets]
command = php %(ENV_APP_DIR)s/artisan websockets:serve
enviroment = PORT="6001"
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes=0
user = root
autostart = true
autorestart = true
priority = 10
stopwaitsecs = 20

App.yaml

runtime: php
env: flex

runtime_config:
  document_root: public

service: orders

skip_files:
  - .env

#only for testing purpose. 
manual_scaling:
  instances: 1

env_variables:
  APP_NAME: "Havn"
  BROADCAST_DRIVER: pusher
  PUSHER_APP_ID: SOMEID
  PUSHER_APP_KEY: SOMEKEY
  PUSHER_APP_SECRET: SOMESECRET
  PUSHER_APP_CLUSTER: mt1
  LARAVEL_WEBSOCKETS_PORT: 6001
  PUSHER_SCHEME: https
  PUSHER_HOST: 127.0.0.1
  PUSHER_PORT: 6001
  QUEUE_DRIVER: database

beta_settings:
  cloud_sql_instances: "INSTANCE ID"

推荐答案

您可以在官方文档中找到如何使用WebSockets建立从客户端(例如移动设备或计算机)到App Engine的持久连接.实例.

You can find in the official documentation how to use WebSockets to create a persistent connection from a client (such as a mobile device or a computer) to an App Engine instance.

请注意WebSockets连接将在一小时后超时.

Please consider that WebSockets connection will time out after one hour.

使用WebSockets PHP创建持久连接

这篇关于如何在GCP Flex环境上设置websocket?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆