【发布时间】:2018-08-05 05:46:25
【问题描述】:
我想在 appengine flexible 中有一个服务,它有一个 UDP 服务器,它接收给定端口上的传入 udp 流量并将其重定向到 appengine 标准中使用 HTTPS 的另一个服务。
据我了解,flex 环境允许打开 UDP 侦听套接字,实际上我的应用程序可以正常启动服务器。但是,我无法让任何流量到达 UDP 服务器。
我怀疑问题是 GAE 或 Docker 配置问题,但我无法在线找到文档或类似问题来解决它。 appengine flexible 的所有 Google 文档都围绕 HTTPS。因此,任何指导都会有所帮助。我有几个问题我认为与我对灵活 Appengine、VM 和 Docker 的理解有关:
- flex appengine 是否应该用作 UDP 服务器?缺少 关于 UDP 负载平衡的文档似乎表明我没有...... 如果这在路线图中有什么想法吗?
- 如果支持,我应该将我的 UDP 流量定向到哪个 IP/URL?是 my-project 吗?应用点。 com 或每个单独的 VM 实例(这似乎是个坏主意,因为 VM 是短暂的)?
这是我当前的应用程序
app.yaml
如您所见,我按照here 的说明转发了我的监听 UDP 端口
runtime: python
env: flex
entrypoint: python main.py
runtime_config:
python_version: 2
network:
forwarded_ports:
- 13949/udp
service: udp-gateway
# This sample incurs costs to run on the App Engine flexible environment.
# The settings below are to reduce costs during testing and are not appropriate
# for production use. For more information, see:
# https://cloud.google.com/appengine/docs/flexible/python/configuring-your-app-with-app-yaml
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10
对于服务器,我在线程模式下使用 python SocketServer,并且我将主线程保持在无限循环中,以免退出服务器。
我还在我的 GCP 控制台中添加了 防火墙 规则:
{
"allowed": [
{
"IPProtocol": "udp",
"ports": [
"13949"
]
}
],
"creationTimestamp": "2018-02-24T16:39:24.282-08:00",
"description": "allow udp incoming on 13949",
"direction": "INGRESS",
"id": "4340622718970870611",
"kind": "compute#firewall",
"name": "allow-udp-13949",
"network": "projects/xxxxxx/global/networks/default",
"priority": 1000,
"selfLink": "projects/xxxxx/global/firewalls/allow-udp-13949",
"sourceRanges": [
"0.0.0.0/0"
]
}
【问题讨论】:
标签: google-app-engine udp google-cloud-platform google-app-engine-python