Cloud Datastore Emulator 在 Android 测试站中使用时返回 503 'Service Unavailable'
Posted
技术标签:
【中文标题】Cloud Datastore Emulator 在 Android 测试站中使用时返回 503 \'Service Unavailable\'【英文标题】:Cloud Datastore Emulator return 503 'Service Unavailable' when used in Android Test StationCloud Datastore Emulator 在 Android 测试站中使用时返回 503 'Service Unavailable' 【发布时间】:2020-12-02 20:25:45 【问题描述】:我正在尝试使用android Test Station。我下载Android Test Station CLI 并运行./mtt start
,但UI 没有启动。然后我运行docker exec -it mtt cat /data/log/server/current
将日志从 docker 中取出。这是日志
[2020-08-12 17:34:13 +0800] [721] [INFO] Listening at: http://0.0.0.0:8086 (721)
[2020-08-12 17:34:13 +0800] [721] [INFO] Using worker: sync
[2020-08-12 17:34:13 +0800] [736] [INFO] Booting worker with pid: 736
/usr/local/lib/python3.6/dist-packages/unicategories_tools/cache.py:37: UserWarning: Unicode unicategories database is outdated. Please reinstall unicategories module to regenerate it.
'Incompatible unicategories database. '
* Running on http://0.0.0.0:8085/ (Press CTRL+C to quit)
WARNING:root:/usr/lib/google-cloud-sdk/platform/google_appengine/lib/cacerts/urlfetch_cacerts.txt missing; without this urlfetch will not be able to validate SSL certificates.
INFO:root:Skipping SDK update check.
WARNING:root:An exception has been encountered when attempting to use Application Default Credentials: File /tmp/keyfile/key.json (pointed by GOOGLE_APPLICATION_CREDENTIALS environment variable) does not exist!. Falling back on dummy AppIdentityServiceStub.
INFO:root:Starting Cloud Datastore emulator at: http://localhost:8087
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/api_server.py", line 502, in _launch
else 'SCATTERED'))
File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/cloud_emulators/cloud_emulator_manager.py", line 123, in Launch
emulator_cmd=self._cmd, start_options=options, silent=silent)
File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/cloud_emulators/datastore/datastore_emulator.py", line 134, in __init__
if not self._WaitForStartup(deadline):
File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/cloud_emulators/datastore/datastore_emulator.py", line 158, in _WaitForStartup
response, _ = self._http.request(self._host)
File "/usr/lib/google-cloud-sdk/platform/google_appengine/lib/httplib2/httplib2/__init__.py", line 1626, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/usr/lib/google-cloud-sdk/platform/google_appengine/lib/httplib2/httplib2/__init__.py", line 1368, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/usr/lib/google-cloud-sdk/platform/google_appengine/lib/httplib2/httplib2/__init__.py", line 1288, in _conn_request
conn.connect()
File "/usr/lib/google-cloud-sdk/platform/google_appengine/lib/httplib2/httplib2/__init__.py", line 938, in connect
self.sock.connect((self.host, self.port) + sa[2:])
File "/usr/lib/google-cloud-sdk/platform/google_appengine/lib/httplib2/httplib2/socks.py", line 415, in connect
self.__negotiatehttp(destpair[0], destpair[1])
File "/usr/lib/google-cloud-sdk/platform/google_appengine/lib/httplib2/httplib2/socks.py", line 381, in __negotiatehttp
raise HTTPError((statuscode, statusline[2]))
HTTPError: (503, 'Service Unavailable')
INFO:root:Starting API server at: http://127.0.0.1:8083
INFO:root:Starting gRPC API server at: http://localhost:44289
INFO:root:Applying all pending transactions and saving the datastore
INFO:root:Saving search indexes
Cloud Datastore Emulator 似乎返回 503 'Service Unavailable'。
但我确信 Cloud Datastore Emulator 是通过 top
命令运行的。
在python脚本中添加一些日志,我得到启动Cloud Datastore Emulator的命令,即
'/usr/lib/google-cloud-sdk/platform/cloud-datastore-emulator/cloud_datastore_emulator', 'start', '--testing', '--regenerate_indexes=false', '--auto_id_policy=SCATTERED', '--port=8007', '--store_on_disk=true', '--store_index_configuration_on_disk=true', '--index_file=/mtt/index.yaml', '--storage_file=/tmp/mtt/datastore.db', '--require_indexes', '/tmp/tmpwvDVWT'
.
这个命令有问题吗?谁能告诉为什么会出现 503 错误?
【问题讨论】:
【参考方案1】:更新:
我找到了原因。我在 .docker/config.json 中添加 no_proxy 设置,它可以工作! 如果你有类似的问题,只需将 noProxy 设置为 "localhost,127.0.0.1,metadata.google.internal" 即可解决。
【讨论】:
以上是关于Cloud Datastore Emulator 在 Android 测试站中使用时返回 503 'Service Unavailable'的主要内容,如果未能解决你的问题,请参考以下文章
库 appengine.api.datastore 和 com.google.cloud.datastore 有啥区别?
App Engine 上 Cloud Datastore 的客户端库 - NDB 或 google-cloud-datastore
Cloud Firestore 下一代 Cloud Datastore?
无法连接到本地 Google Cloud Datastore 模拟器