我正在尝试将 Loopback 应用程序连接到 Google SQL 数据库,并且我已更改 Datasource.json 文件以匹配凭据。但是,当我在 Loopback API 资源管理器中发出 GET 请求时,出现错误。我没有找到任何关于如何在 Datasource.json 中指定 ssl 凭据的文档,我认为这是导致错误的原因。
我尝试更改 Datasource.json 无果而终,以下是当前状态。我已经更改了隐私的详细信息,但我 100% 确定凭据是正确的,因为我可以与 javascript 成功连接。
{
"nameOfModel": {
"name": "db",
"connector": "mysql",
"host": "xx.xxx.x.xxx",
"port": xxxx,
"user": "user",
"password": "password",
"database": "sql_db",
"ssl": true,
"ca" : "/server-ca.pem",
"cert" : "/client-cert.pem",
"key" : "/client-key.pem"
}
}
这是我在环回 API 资源管理器上尝试 GET 请求时命令行返回的错误。错误:
5000 毫秒后连接超时”让我相信它没有读取 ssl 凭据。
Unhandled error in GET /edd-sales?filter[offset]=0&filter[limit]=0&filter[skip]=0: 500 TypeError: Cannot read property 'name' of undefined
at EddDbDataSource.DataSource.queueInvocation.DataSource.ready (D:\WebstormProjects\EDD-Database\edd-api\node_modules\loopback-datasource-juggler\lib\datasource.js:2577:81)
(node:10176) UnhandledPromiseRejectionWarning: Error: Timeout in connecting after 5000 ms
at Timeout._onTimeout (D:\WebstormProjects\EDD-Database\edd-api\node_modules\loopback-datasource-juggler\lib\datasource.js:2572:10)
at ontimeout (timers.js:498:11)
(node:10176) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:10176) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.